Avoid multiple simulink outputs overwriting
显示 更早的评论
Good morning everybody,
I need a tip for my code: I'm running a simulink model from a matlab script whose inputs depend on several switch commands. I'd like to save the model outputs in one cell for each iteration (I mean for each switch case). I've tried with the code below: a and b are my inputs, which depend on 4 cases op_point and 11 cases i, so at the end I should get 4x11 cells for each output (States, States1, Outputs, Und_par, PLA_out). But I do not obtain any cell, only a matrix, as if each iteration overwrites the previous results. How can I retain all past iterations in cells?
Thanks
try sim('mymodel')
for t=1:size((States),1)
a{op_point,i}(t,:)=inp2{1,op_point};
b{op_point,i}(t,:)=Inp{1,i};
c{op_point,i}(t,:)=[States{op_point,i}(:,:)];
d{op_point,i}(t,:)=[States1{op_point,i}(:,:)];
e{op_point,i}(t,:)=[Outputs{op_point,i}(:,:)];
f{op_point,i}(t,:)=[Und_par{op_point,i}(:,:)];
g{op_point,i}(t,:)=[PLA_out{op_point,i}(:,:)];
end
end
3 个评论
Mathieu NOE
2021-9-27
hello
IMHO, it would be simpler to create a matlab script with a nested for loop where you can change the parameters (switch commands) that will be passed then to sim('mymodel')
from there it should be much simpler to save each simulation output
Antonio Tricarico
2021-9-27
Mathieu NOE
2021-9-28
hello again
so could you save the full simulink output along with the iteration index
then it should be easy from matlab to split the data into piece based on what "iteration" is (from the record
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Modeling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!