Evaluate Simulink model at a given time vector
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi all,
I have a Simulink model that I run from Matlab and I also use the block "from workspace" to load some data. As you know, I also have to load the time stamp alongside the data I want to use.
Now, I need to enforce Simulink to evaluate the model at the times stated in the block "from workspace". Ideally, this wouldn't require any interpolation in the block "from workspace".
Example:
I load this dummy DATA in my model
DATA = [0, 0;...
1, 10;...
1.3, 18;...
2.1; 21]
where [0, 1, 1.3, 2.1] is the time stamp and [0, 10, 18, 21] is the vector I need. I want Simulink to evaluate the model exactly at times [0, 1, 1.3, 2.1]. It's like a very special variable time step that I would like to enforce.
I hope I have explained clearly what I need.
Thank you everyone in advance!
0 comentarios
Respuestas (2)
Salman Ahmed
el 31 de Dic. de 2021
Hi Daniele,
Assuming you wish to produce the simulation outputs at specified times, navigate to the model configuration settings under Data Import/Export option, find "Output Options" in Additional Parameters. Set this parameter to "Produce specified output only". Then you can specify the "Output Times" array for which you want to produce the output.
1 comentario
Ahmed Mahfouz
el 25 de Abr. de 2025
Hello Daniele,
I was having the exact same issue, and the following method worked for me, so you might as well wanna try it.
simOut = sim(model_name, 'OutputOption', 'SpecifiedOutputTimes', 'OutputTimes', sprintf('[%s]', num2str(required_time_vec(:)')));
The reason I used
required_time_vec(:)'
instead of simply
required_time_vec
is that I needed to make sure that the required time vector is passed to the num2str function as a raw vector.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!