How can i force simulink to use a set of data from another simulink model ?
1 次查看(过去 30 天)
显示 更早的评论
Hey,
I have a Simulink File, which generates some Data and exports it to my Workspace. My second Simulink file needs this data and therefore imports it. This also works wonderfully when I run each individual simulation myself. But now I want everything to run automatically with one click. So first simulation1 -> data is loaded -> simulation2 runs.
I have already tried it with the following code:
set_param('simulation1', SimulationCommand', 'start');
data_simulation2 = data_simulation1 + offset;
set_param('simulation2', SimulationCommand','start');
But the problem is that both simulations run, but the data is not transferred to the second simulation. Only after the second simulation is finished, the data is loaded.
LG
Lindrit
0 个评论
采纳的回答
Paul
2022-4-17
Try using the sim() command instead of set_param. I had trouble with the latter, but no problems with the former. This code worked fine for me, where y1 is a ToWorkspace output from sim1 and u2 is block paramter in sim2.
clear
out1 = sim('sim1');
u2 = out1.y1.Data;
out2 = sim('sim2');
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Programmatic Model Editing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!