フィルターのクリア

How can i force simulink to use a set of data from another simulink model ?

1 回表示 (過去 30 日間)
Lindrit Hasani
Lindrit Hasani 2022 年 4 月 17 日
回答済み: Paul 2022 年 4 月 17 日
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

採用された回答

Paul
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 件)

カテゴリ

Help Center および File ExchangeSources についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by