运行 Matlab 模拟并创建带有模拟结果的 JMP 数据表各位,
我正在使用 JMP 运行 #Matlab 模拟。 我使用 JMP 创建了一个设计,其中包含三个因子(par1、par2 和 par3)和几个用于响应的空列(y1、y2)。 我创建了一个 JSL 脚本,为设计的每一行运行 Matlab 代码并获取仿真结果(三个向量:时间、y1 和 y2;y1 和 y2 实际上是时间的函数)。 现在我想用 par1、par2、par3、time、y1 和 y2 创建一个 JMP 数据表。 当然,对于给定的模拟 par1、par2 和 par3 必须在模拟中重复相同的值。 这是我要创建的新表的示例。 谁能告诉我一旦将时间、y1 和 y2 作为列导入 JMP 后,我应该如何处理 JSL 代码?
非常感谢。
par1 par2 par3 时间 y1 y2
3 1 1 1 ......
3 1 1 2 ......
3 1 1 3 ......
4 1 1 1 ......
4 1 1 2 ......
4 1 1 3 ......
美国能源部脚本编写回复:运行 Matlab 模拟并创建带有模拟结果的 JMP 数据表我通常通过创建一个看起来像我想要的单行的新表,在 GUI 中创建输出表的格式。 然后使用红色三角形得到表脚本(无数据) . 将该脚本粘贴到编辑器中,dt =粘贴;
然后从您刚刚粘贴的脚本中删除 addrows,只留下列定义。 如果它出现,也删除选定的列位。
您编写的用于填充表的循环将对每一行使用 addrows(1) 并在该行上设置每个变量。 默认行将是刚刚添加的行,所以
for( ... ,
dt<<ADDROWS></ADDROWS>这是在每个循环中添加三行的示例https://community.jmp.com/t5/Discussions/Difference-of-lines/mp/417373/highlight/true#M66646 .
回复:运行 Matlab 模拟并创建带有模拟结果的 JMP 数据表你好,
谢谢你的代码,很有用。
我仍然需要一些帮助。 我的问题是时间不是原始设计的一个因素。 最初的设计只有 par1、par2 和 par3。 对于 par1、par2 和 par3 的每个组合,JMP 运行 Matlab 并得到三个向量(t, y1 和 y2)。 我如何要求 JMP 将这三个向量添加到结果数据表中,使 par1、par2 和 par3 的值重复 n 次,其中 n 是 t 向量的维度?
谢谢。
回复:运行 Matlab 模拟并创建带有模拟结果的 JMP 数据表这是一些未经测试的伪代码,可能适合您所描述的内容
for( par1 = 1, par1 <= 3, par1+=1, // 3...how ever many combinations there are
for(par2 = 1, par2 <= 5, par2 +=1, // 5
for(par3 = 1, par2 <= 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<= n, i+=1, // n is the vector length, write a row for each element
dt<<ADDROWS></ADDROWS>... close all the parens ...我将表变量 p1 命名为 par1 以简化列名与变量名相同时的范围问题。 我想象你为 par1、2、3 的每个组合分别调用 matlab。 我想象这些向量显示为 JSL 矩阵。 Factors and Designs 和 matlab 不是我的强项,我可能误解了这个问题。
回复:运行 Matlab 模拟并创建带有模拟结果的 JMP 数据表非常感谢您的帮助。 根据您的建议,我能够编写解决我的问题的 jsl 代码。 这是代码。
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 << addrows( n ); // for each simulation add n rows to the simulation table
For( i = 1, i <= 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;
);
);