to run simulink model from script and save data to workspace after each simulation and then repeat for 256 times.
4 次查看(过去 30 天)
显示 更早的评论
I am reading data frm the workspace and that data is 256x256. I read data of first row and then run simulation on it and get the output recorded in workspace .This procces goes on till I have got 256x256 output. I need to know how to save data after each simulation so that at the end I get 256x256 matrix in output and then how to use this data.
0 个评论
回答(1 个)
Sulaymon Eshkabilov
2021-6-19
In this exercise, you had better employ sim() to run your Simulink model from MATLAB environment. To achieve your goal of collecting simulation results after every simulation, you should use:
(1) In Simulink model, use [From WorkSpace] and [To WorkSpace] blocks, which are used to get the data from MATLAB to simulate the model and send the results back to MATLAB workspace.
(2) In MATLAB code, use sim() to run the SImulink model within a loop. E.g.:
K = ...; % 256 - by - 256
for ii = 1:256
A = K(ii,:); % Call each row of data from [K] and use for simulation. [From WorkSpace] variable's name is A
OUT(ii)= sim('M_Run.slx'); % Simulink model called M_Run.slx. All simulation results saved under the var name OUT (that can be set up as structure or array)
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Event Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!