Save an output each simulation
古いコメントを表示
Hi, I built a model in simulink, wich is feed with a variable input using this code:
mdl = 'PSDfaulty';
x = [0.8:0.01:0.95];
for i = 1:numel(x)
set_param([mdl '/FrontFault'] , 'Value' , num2str(x(i)));
simout = sim(mdl);
end
and it works perfectly, now I need to save in the workspace the output of the model for each simulation, if possible by modifying the code. Im using a simout block but it only saves the last value, Any advice? Thanks.
6 件のコメント
Walter Roberson
2019 年 7 月 30 日
simout{i} = sim(mdl) ;
Possibly you might be able to assign to simout(:, i) instead of using a cell array.
Sergio Rueda
2019 年 7 月 31 日
Walter Roberson
2019 年 7 月 31 日
mdl = 'PSDfaulty';
x = [0.8:0.01:0.95];
nx = length(x);
simouts = cell(nx, 2); %2 is how many of the outputs you want to save
for i = 1:nx
set_param([mdl '/FrontFault'] , 'Value' , num2str(x(i)));
[out1, out2, out3, out4] = sim(mdl); %use appropriate number
simouts{i, 1} = out2; simouts{i, 2} = out4; %save the ones you want
end
Sergio Rueda
2019 年 7 月 31 日
編集済み: Sergio Rueda
2019 年 7 月 31 日
Walter Roberson
2019 年 7 月 31 日
I am not certain but I suspect that you will need 3 outputs from the sim() command and that all of the interesting values are muxed together in the third output. However at the moment I am not sure what datatype that third output would be or how the values would be arranged for it.
Sergio Rueda
2019 年 7 月 31 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Save Run-Time Data from Simulation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
