Can't save Simulink simulation results after changing parameter

Hey everybody,
so I have a Simulink simulation where I vary a parameter
for i=1:length(parameter)
Input_var=parameter(i)
sim(modelname)
simout_store(:,i)=simout(:,1) %simout is a "to workbench" output in the simulation
end
But all I get is this error "Subscripted assignment dimension mismatch." How can I fix this? I just want to save the results after every simulation before it gets overridden

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 3 月 27 日

0 投票

Use a cell array
simout_store{i}=simout(:,1)

3 件のコメント

Tomtom
Tomtom 2016 年 3 月 28 日
Thanks it works. The problem is, simout_store has the dimension 1x6608 after the first simulation and 1x6609 after the second. That made the error. Still doesn't know why though.
Azzi Abdelmalek
Azzi Abdelmalek 2016 年 3 月 28 日
If the step time is not fixed, you can get any number of samples
Tomtom
Tomtom 2016 年 3 月 28 日
Jepp that will be the problem...
set_param(modelname,'SolverType','Variable-Step');
set_param(modelname,'maxstep','0.0015');
set_param(modelname,'minstep','auto');
set_param(modelname,'Solver','ode23s');
set_param(modelname,'StartTime','0');
set_param(modelname,'StopTime','10');
What would be better settings? If I want to:
plot(simout_time,simout_store{1,1})
I still get an error because simout_time is 1 shorter than simout_store.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

2016 年 3 月 26 日

コメント済み:

2016 年 3 月 28 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by