How can I save partial results of a simulation that exited with error when running it programmatically?
10 ビュー (過去 30 日間)
古いコメントを表示
Claudius Rosendahl
2022 年 12 月 5 日
回答済み: Joel Van Sickel
2022 年 12 月 12 日
I have a Simscape simulation that writes results to the variable out. I'm trying different sets of parameters for my PID controller. Sometimes the simulation fails (due to physical constrains that are violated).
I realised that partial results are saved only if the simulation is run "manually" (by pressing the play button). By partial results I mean that timeseries for my output variables are written up to the point when the simulation fails.
As an example, lets assume my simulation is supposed to run for 1000s, but fails at 603s.
If run via play button, the variable out.power contains a timeseries of the data up to second 603. If run programmatically, out does not exist.
out=sim(mymodel);
I'm having a hard time coming up with a minimal example of a simulation that fails at a certain point in time, so please excuse the lack of such an example.
I was hoping there was some option for that but I've come up empty handed in my search.
0 件のコメント
採用された回答
Joel Van Sickel
2022 年 12 月 12 日
There is a way to do this using a setting StopOnError and setting it to off. I created a test file that crashes (I create a divide by zero uisng the ps divide in the simscape domain). To use this feature, you have to use the simulation input class. I created a very basic example below:
file = 'temptestsim'
simIn = Simulink.SimulationInput(file);
out2 = sim(simIn,"StopOnError","off")
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!