運行 Matlab 模擬並建立包含仿真結果的 JMP 資料表各位,
我正在使用 JMP 運行 #Matlab 模擬。我使用 JMP 創建了一個設計,其中包含三個因子(par1、par2 和 par3)以及幾個用於回應的空列(y1、y2)。我創建了一個 JSL 腳本,為設計的每一行運行 Matlab 程式碼並獲取模擬結果(三個向量:時間、y1 和 y2;y1 和 y2 實際上是時間的函數)。現在我想建立一個包含 par1、par2、par3、時間、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 數據表非常感謝您的幫助。 根據您的建議,我能夠編寫一個 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;
);
);
回复:運行 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 數據表你好,
感謝您的代碼,它很有用。
我還需要一些幫助。 我的問題是時間不是原始設計的一個因素。 最初的設計只有par1、par2和par3。 對於 par1、par2 和 par3 的每個組合,JMP 運行 Matlab 並獲得三個載體(t、y1 和 y2)。 我如何要求 JMP 將這三個向量添加到結果數據表中,使 par1、par2 和 par3 的值重複 n 次,其中 n 是 t 向量的維度?
謝謝。
回复:運行 Matlab 模擬並創建包含模擬結果的 JMP 數據表我通常在 GUI 中創建輸出表的格式,方法是製作一個新表,其中一行看起來像我想要的。 然後使用紅色三角形得到表腳本(無數據) . 將該腳本粘貼到編輯器中,dt =粘貼;
然後從您剛剛粘貼的腳本中刪除 addrows,只留下列定義。 也刪除選定的列位,如果它出現的話。
您為填充表而編寫的循環將為每一行使用 addrows(1) 並在該行上設置每個變量。 默認行將是剛添加的行,所以
for( ... ,
dt<<ADDROWS></ADDROWS>
這是一個在每個循環中添加三行的示例線差.