How can i force simulink to use a set of data from another simulink model ?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Lindrit Hasani
am 17 Apr. 2022
Beantwortet: Paul
am 17 Apr. 2022
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 Kommentare
Akzeptierte Antwort
Paul
am 17 Apr. 2022
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Sources finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!