How do I run simulink in matlab script and use that result of simulation in matlab again?

44 Ansichten (letzte 30 Tage)
I saw that I can use 'sim' function to run simulink file in matlab script.
I also saw that I can use 'to workspace' block to export simulink data to matlab workspace.
So I constructed matlab script like this:
list of parameters
sim('Project_quartercar_example.slx')
y1=max(out.simout(:,1))
When I change parameters and run this script, the simulation runs(the graph in scope block changes)
But y1 doesn't change automatically. It only changes when I run simulation on simulink directly.
How can I solve this problem?

Akzeptierte Antwort

Sulaymon Eshkabilov
Sulaymon Eshkabilov am 4 Jun. 2021
Bearbeitet: Sulaymon Eshkabilov am 4 Jun. 2021
Run these edited comands instead:
OUT = sim('Project_quartercar_example.slx');
y1=max(OUT.simout(:,1));
t = OUT.tout;
plot(t, y1)

Weitere Antworten (0)

Kategorien

Mehr zu View and Analyze Simulation Results finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by