To save a plot generated using the ‘Scope’ block in a Simulink model, certain properties of the Scope block must be modified. Follow these steps to adjust the necessary settings:
- Open the Scope block and navigate to Settings.
- Go to the Logging tab.
- Enable Log data to workspace.
- Set the Variable Name to “simout” and the Save Format to Structure with time.
Once the simulation is complete, execute the following commands in the MATLAB command window to save the figure:
time = simout.time;
data = simout.signals.values;
plot(time, data);
saveas(gcf, 'myPlot.png');
For additional details, refer to the official MATLAB documentation using the following commands:
web(fullfile(docroot, '/simulink/slref/scope.html'))
web(fullfile(docroot, '/matlab/ref/saveas.html'))