MATLAB error handling of SIMULINK (sim) due to external component
6 views (last 30 days)
Show older comments
Hello all
My problem is that I am running a sweep study with some parameters. I change them in MATLAB and then run a simulation in MATLAB with the sim command. The simulation in SIMULINK contains an external software component from COMSOL with an FEM behind it. In some cases where the configuration is unfavorable (rapid changes in the feedback loop of the controlled system), the FEM tool is not able to converge in finite time, resulting in an error after a few simulation seconds/minutes/hours. The simulation command is inside a try-catch section to avoid that the program is stopped and the next study step starts to process the acquired data.
The problem is that in case the simulation has a convergence problem, the data generated up to this error is not sent to the workspace, but would be valid, and so I cannot find out from the data what was the reason for the convergence problem.
As additional information, I have been using the ToWorkspace block to send the data to my workspace where I do my post processing, and that works fine when the simulation is complete.
If any of you have any ideas on how to solve this problem, maybe you can help me. Thank you in advance.
0 Comments
Accepted Answer
C B
on 12 Dec 2022
One way to handle this problem is to use the "To File" block in Simulink instead of the "To Workspace" block. This will save the data to a file on your computer, instead of just sending it to the workspace. You can then use the "From File" block to read the data back into the workspace after the simulation is complete. This way, even if the simulation encounters an error and is unable to continue, you will still have access to the data that was generated up to that point.
1 Comment
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!