How to cache data while in for loop

1 Ansicht (letzte 30 Tage)
Tomtom
Tomtom am 27 Mär. 2016
Beantwortet: Walter Roberson am 27 Mär. 2016
Hey everybody,
so I have a Simulink simulation where I vary a parameter
for i=1:length(parameter)
Input_var=parameter(i) % input for simulation
sim(modelname) % simulate the model
sim_out_store(:,i)=sim_out(:,1) % sim_out 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 in the next loop cycle.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 27 Mär. 2016
Probably sim_out is sometimes empty. You cannot store empty results in a numeric array. Use a cell array instead.
sim_out_store{i} = sim_out(:,1);

Weitere Antworten (0)

Kategorien

Mehr zu Simulink finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by