to run simulink model from script and save data to workspace after each simulation and then repeat for 256 times.
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Sulaymon Eshkabilov
el 19 de Jun. de 2021
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 comentarios
Ver también
Categorías
Más información sobre Event Functions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!