<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Run Matlab simulations and create a JMP data table with simulations results in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Run-Matlab-simulations-and-create-a-JMP-data-table-with/m-p/417643#M66675</link>
    <description>&lt;P&gt;I usually create the output table's format in the GUI by making a new table with a single row that looks like what I want. Then use the red triangle to get the &lt;EM&gt;table script (no data)&lt;/EM&gt;. Paste that script into a editor, dt = &lt;EM&gt;paste&lt;/EM&gt;;&lt;/P&gt;
&lt;P&gt;Then remove the addrows from the script you just pasted, leaving just the column definitions. Remove the selected column bit too, if it shows up.&lt;/P&gt;
&lt;P&gt;The loop you write to populate the table will use addrows(1) for each row and set each variable on that row. The default row will be the row just added, so&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;for( ... ,
    dt&amp;lt;&amp;lt;addrows(1);
    dt:par1 = ...;
    dt:par2 = ...;
    ...
    dt:y1 = ...;
    ...
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here's an example that added three rows in each loop&amp;nbsp;&lt;LI-MESSAGE title="Difference of lines" uid="416953" url="https://community.jmp.com/t5/Discussions/Difference-of-lines/m-p/416953#U416953" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&lt;SPAN style="font-family: inherit;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Sep 2021 15:32:11 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2021-09-13T15:32:11Z</dc:date>
    <item>
      <title>Run Matlab simulations and create a JMP data table with simulations results</title>
      <link>https://community.jmp.com/t5/Discussions/Run-Matlab-simulations-and-create-a-JMP-data-table-with/m-p/417625#M66670</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;I am using JMP to run #Matlab simulations. I created a design with JMP that has three factors (par1, par2 and par3) and several empty columns for the responses (y1, y2). I created a JSL scripts that for each row of the design runs the Matlab code and gets the results of the simulation (three vectors: time, y1 and y2; y1 and y2 are in fact functions of time). Now I would like to create a JMP data table with par1, par2, par3, time, y1 and y2. Of course, for a given simulations par1, par2 and par3 have to have the same values repeated along the simulation. Here is an example of the new table that I would like to create. Can anyone tell me how I should approach the JSL code for that once I have imported time, y1 and y2 as columns into JMP?&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;par1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; par2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; par3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y2&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..&lt;/P&gt;&lt;P&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..&lt;/P&gt;&lt;P&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..&lt;/P&gt;&lt;P&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:56:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Run-Matlab-simulations-and-create-a-JMP-data-table-with/m-p/417625#M66670</guid>
      <dc:creator>MFVIT</dc:creator>
      <dc:date>2023-06-09T19:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Run Matlab simulations and create a JMP data table with simulations results</title>
      <link>https://community.jmp.com/t5/Discussions/Run-Matlab-simulations-and-create-a-JMP-data-table-with/m-p/417643#M66675</link>
      <description>&lt;P&gt;I usually create the output table's format in the GUI by making a new table with a single row that looks like what I want. Then use the red triangle to get the &lt;EM&gt;table script (no data)&lt;/EM&gt;. Paste that script into a editor, dt = &lt;EM&gt;paste&lt;/EM&gt;;&lt;/P&gt;
&lt;P&gt;Then remove the addrows from the script you just pasted, leaving just the column definitions. Remove the selected column bit too, if it shows up.&lt;/P&gt;
&lt;P&gt;The loop you write to populate the table will use addrows(1) for each row and set each variable on that row. The default row will be the row just added, so&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;for( ... ,
    dt&amp;lt;&amp;lt;addrows(1);
    dt:par1 = ...;
    dt:par2 = ...;
    ...
    dt:y1 = ...;
    ...
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here's an example that added three rows in each loop&amp;nbsp;&lt;LI-MESSAGE title="Difference of lines" uid="416953" url="https://community.jmp.com/t5/Discussions/Difference-of-lines/m-p/416953#U416953" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&lt;SPAN style="font-family: inherit;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 15:32:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Run-Matlab-simulations-and-create-a-JMP-data-table-with/m-p/417643#M66675</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2021-09-13T15:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: Run Matlab simulations and create a JMP data table with simulations results</title>
      <link>https://community.jmp.com/t5/Discussions/Run-Matlab-simulations-and-create-a-JMP-data-table-with/m-p/418146#M66717</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;thanks for you code, it was useful.&lt;/P&gt;&lt;P&gt;I still need some help. My problem is that time is not a factor of the original design. The original design has only par1, par2 and par3. For each combination of par1, par2 and par3 JMP runs Matlab and gets three &lt;STRONG&gt;vectors&lt;/STRONG&gt; (t, y1 and y2). How can I ask JMP to add these three vectors to the result data table in such a way that I have the values for par1, par2 and par3 repeated n times, where n is the dimension of the t vector?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 13:54:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Run-Matlab-simulations-and-create-a-JMP-data-table-with/m-p/418146#M66717</guid>
      <dc:creator>MFVIT</dc:creator>
      <dc:date>2021-09-14T13:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: Run Matlab simulations and create a JMP data table with simulations results</title>
      <link>https://community.jmp.com/t5/Discussions/Run-Matlab-simulations-and-create-a-JMP-data-table-with/m-p/418210#M66724</link>
      <description>&lt;P&gt;here's some untested pseudo code that might fit what you are describing&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;for( par1 = 1, par1 &amp;lt;= 3, par1+=1, // 3...how ever many combinations there are
  for(par2 = 1, par2 &amp;lt;= 5, par2 +=1, // 5
    for(par3 = 1, par2 &amp;lt;= 2, par3+= 1, // 2
      /* get the vectors from matlab using par1,par2,par3 */
      /* somehow mat_t, mat_y1, and mat_y2 are now JSL matrices, n rows by 1 col */
      for( i = 1, i&amp;lt;= n, i+=1, // n is the vector length, write a row for each element
        dt&amp;lt;&amp;lt;addrows(1);
        dt:y1 = mat_y1[i];  // different values for n rows. also for y2
        dt:t = mat_t[i];
        dt:p1 = par1; // repeats same value for n rows.&amp;nbsp;also&amp;nbsp;for&amp;nbsp;p2,&amp;nbsp;p3&lt;BR /&gt;...&amp;nbsp;close&amp;nbsp;all&amp;nbsp;the&amp;nbsp;parens&amp;nbsp;...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I named the table variable p1 for par1 to simplify the scoping issues when column names are the same as variable names. I imagined you make separate calls to matlab for each combination of par1,2,3. I imagined those vectors show up as JSL matrices. Factors and Designs and matlab are not my strong area, I may be misunderstanding the issue.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 16:02:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Run-Matlab-simulations-and-create-a-JMP-data-table-with/m-p/418210#M66724</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2021-09-14T16:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Run Matlab simulations and create a JMP data table with simulations results</title>
      <link>https://community.jmp.com/t5/Discussions/Run-Matlab-simulations-and-create-a-JMP-data-table-with/m-p/421527#M67040</link>
      <description>&lt;P&gt;Thank you very much for your help. Based on your suggestions I was able to write a jsl code that solved my problem. Here is the code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;MATLAB Submit( "iii=0;" ); // Initialize the counter in Matlab

For Each Row(
    dt1, 

    row_n_dt1 = row_n_dt1 + 1;

    v0 = :Pattern[row_n_dt1];
    v1 = :F1[row_n_dt1];
    v2 = :F2[row_n_dt1];
    v3 = :F3[row_n_dt1];
    MATLAB Submit( "iii=iii+1;" );

    MATLAB Send( v1 );
    MATLAB Send( v2 );
    MATLAB Send( v3 );

    MATLAB Submit( "FF1=v1" );
    MATLAB Submit( "FF2=v2" );
    MATLAB Submit( "FF3=v3" );

    MATLAB Submit( "main_II" ); // execute the code contained in the matlab file 'main_II'

    MATLAB Submit( "xlswrite(filename, [t y],iii);" ); // write an excel file with all the simulation results; each sheet contains a simulation

    MATLAB Submit( "y1=y(:,1);" ); // create the vector y1 in Matlab
    MATLAB Submit( "y2=y(:,2);" ); // create the vector y2 in Matlab
    MATLAB Submit( "whos" );

    mat_y1 = MATLAB Get( y1 ); // JMP imports vectors y1, y2 and t as matrices
    mat_y2 = MATLAB Get( y2 );
    mat_t = MATLAB Get( t );

    n_timevector = Dim( mat_t ); // dimensions of matrix mat_t
    n = n_timevector[1]; // lenght of vector t

    //i=1;
    dt2 &amp;lt;&amp;lt; addrows( n ); // for each simulation add n rows to the simulation table

    For( i = 1, i &amp;lt;= n, i += 1, // n is the vector length, write a row for each element of the time vector in table dt2

        row_n_dt2 = row_n_dt2 + 1;
        dt2:Pattern[row_n_dt2] = v0;
        dt2:x1[row_n_dt2] = mat_y1[i]; // different values for n rows
        dt2:M[row_n_dt2] = mat_y2[i];
        dt2:t[row_n_dt2] = mat_t[i];
        dt2:F1[row_n_dt2] = v1; // repeats same value for n rows
        dt2:F2[row_n_dt2] = v2;
        dt2:F3[row_n_dt2] = v3;

    );
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 12:49:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Run-Matlab-simulations-and-create-a-JMP-data-table-with/m-p/421527#M67040</guid>
      <dc:creator>MFVIT</dc:creator>
      <dc:date>2021-09-28T12:49:56Z</dc:date>
    </item>
  </channel>
</rss>

