Importing a SIMULINK model to workspace and using the model for output generation
24 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hey there,
I created a model in SIMULINK and I have 16 signals that I want to feed in to this system and obtain the outputs individually with coding in MATLAB.
I can do this one by one using the From Workspace and To Workspace Blocks in SIMULINK, however I want to do this many times using a single for loop in MATLAB.
How can I load the system to MATLAB workspace, feed my signals one by one and store the output?
Thanks a lot !
0 comentarios
Respuestas (1)
Samatha Aleti
el 27 de En. de 2020
Editada: Samatha Aleti
el 28 de En. de 2020
Hi,
According to my understanding, you are trying to run a SIMULINK model with different values each time one after other, from MATLAB. You can do this with the help of “sim” command and “set_param” command. Here is a sample MATLAB script to do this:
y = zeros(1,10); % Let
A = 0; % Let
for i = 1:10
A = A +1;
set_param('SimLoop/Constant','Value','A') % Changing the constant value for each simulation
out = sim('SimLoop'); % Run model
y(i) = out.yout.Data; % Save output
end
I have attached the SIMULINK model “SimLoop” that I used in this example for better understanding. This is basic example to help you understand how to use commands to load and configure a SIMULINK model, you may have to add or modify to get your desired behaviour.
You can also use the command “parsim” to run multiple simulations in parallel, Refer the following document link for detailed explanation:
Following is the document link on Programmatic Modeling:
Ver también
Categorías
Más información sobre Programmatic Model Editing 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!