a serialized simulation in Simulink

1 次查看(过去 30 天)
Ehsan
Ehsan 2023-1-13
评论: Ehsan 2023-1-16
I am going to get some values from Simulink and return them back to Simulink with some changes. What I need is a serialized simulation where the output of the first simulation is sent to the second simulation. The result of the second simulation is important to me. How can I run this serialized simulation in Simulink?
  2 个评论
Fangjun Jiang
Fangjun Jiang 2023-1-13
编辑:Fangjun Jiang 2023-1-13
For a Simulink simulation, there is a Simulink model. You provide some input data, run the simulation and get some output data.
When you talk about first and second simulation, are you talking about running the simulation twice with the same model? or something else, like the output of one model is sent to the second model?
If it is running simulation twice, it sounds like you want the output data of the first simulation to be used as the input data for the second simulation. Then what and how do you provide the input data for the first simulaton?
Ehsan
Ehsan 2023-1-14
Thank you for your response, yes, I have one Simulink model, and I want to run it twice.
as you can see in the following picture, I have a value named "t" in my model, it is my input value and has a initial value in my code in order to run my simulation in the first run. then, I am going to read some other values (my Simulink outputs for my m file) from the Simulink to calculate new "t" (for example t1 through my codes) and set t1 with the old "t" value and run my model for the second time by my code.

请先登录,再进行评论。

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2023-1-15
This should be a relatively easy task. I think the best way is to implement it in the "StopFcn" callback of the model.
Open the model, click file, properties, callbacks, and type in your script at the "StopFcn", which calculates and over-write the value of "t".
Make your processing a .m Script, not a .m Function, so you can access the base worspace variable directly.

类别

Help CenterFile Exchange 中查找有关 Model, Block, and Port Callbacks 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by