Borrar filtros
Borrar filtros

How do I use as an input specific values?

1 visualización (últimos 30 días)
Bob
Bob el 24 de Jul. de 2016
Comentada: Star Strider el 24 de Jul. de 2016
I have an output data from a simulink model.
I want to save the output data inside a loop for a two different input values.
How can I do that?
For example, I want to have, np = 800, as input in my simulink model and after that I want to save it as .mat file.
After that I want to do the same thing for input np = 1000.
for ii=1:199:200
np = 800+ii; % input variable to simulink model
sim('Simulink_Model'); % output data
M(:,ii)=Data;
end
save('Data.mat','M'); % save('FileName','Variables');
The above code gives me a M with 200 columns instead of 2 columns...

Respuesta aceptada

Star Strider
Star Strider el 24 de Jul. de 2016
It is giving you 200 columns because you asked it to. I don’t have much recent Simulink experience, but perhaps something like this is what you want:
save_cols = 199:200;
for ii=1:length(save_cols)
np = 800+save_cols(ii); % input variable to simulink model
sim('Simulink_Model'); % output data
M(:,ii)=Data;
end
NOTE — This is UNTESTED CODE. It should work and it will probably give you the result you want.
  2 comentarios
Bob
Bob el 24 de Jul. de 2016
Thanks again!!!
Star Strider
Star Strider el 24 de Jul. de 2016
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by