How to cache data while in for loop
조회 수: 2 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
Walter Roberson
2016년 3월 27일
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);
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Configure and View Diagnostics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!