Running simulink model with multiple values of a parameter, and then plotting multiple results on the same plot
40 次查看(过去 30 天)
显示 更早的评论
I have a simulink model (a DC-DC boost converter) that I can run, where there is a parameter called "Beta" that affects the step response. I have oscilloscopes connected to the output.
--> In my parent .m file, I want to run the simulink model several times. For instance:
"Open my_model.slx, set Beta to 0.5, then simulate, and plot output voltage"
"Open my_model.slx, set Beta to 0.6, then simulate, and plot output voltage on the SAME plot as above"
"Open my_model.slx, set Beta to 0.7, then simulate, and plot output voltage on the SAME plot as above"
...etc.
This way, I can see which value of Beta gives me the "best" response. I know I need the "hold on" command to keep data on the same plot. How do I output oscilloscope data from the simulink model to the workspace, so that I can plot it?
0 个评论
采纳的回答
Paul
2023-2-17
Check out this doc page for an example of how to run multiple simulations with different parameters. You can use sim instead of parsim. sim is probably easier for just three runs.
After the simulations are complete the data from all three simulations will be in the variable 'out', or whatever you call the output of the sim command. Each element of out is a Simulink.SimulationOutput object. See the doc page on how to access the simulation outputs from each element of out for plotting. Yes, plot each one separately using the hold command between plots.
Make sure the Single Simulation Output is enabled on the Model Settings -> Data Import/Export pane. It's probably enabled already by default.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 View and Analyze Simulation Results 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!