cannot save figure from simulink

2 次查看(过去 30 天)
whenever i try to save a plot generated from the simulink it is saved as an emty handle. and i get the following error
i am using 2016a version.
Warning: While saving an object of class 'matlabshared.scopes.UnifiedScope':
Method 'saveobj' is not defined for class 'matlabshared.scopes.UnifiedScope' or is removed from MATLAB's search path.
> In matlab.graphics.internal.figfile.FigFile/write (line 32)
In savefig (line 84)
In saveasfig (line 6)
In saveas (line 140)
In filemenufcn>localSaveExportHelper (line 216)
In filemenufcn>localSaveExport (line 344)
In filemenufcn (line 56)
In filemenufcn>localSave (line 186)
In filemenufcn (line 54)
Warning: Simulink.BlockDiagram object could not be saved in a MAT-file. It will be saved as an empty handle instead.
> In matlab.graphics.internal.figfile.FigFile/write (line 32)
In savefig (line 84)
In saveasfig (line 6)
In saveas (line 140)
In filemenufcn>localSaveExportHelper (line 216)
In filemenufcn>localSaveExport (line 344)
In filemenufcn (line 56)
In filemenufcn>localSave (line 186)
In filemenufcn (line 54)
Warning: Figure is saved in C:\Users\praween\Desktop\untitled.fig. Saving graphics handle variables can cause the creation of
very large files. To save graphics figures, use savefig.
> In matlab.graphics.internal.figfile.FigFile/write (line 32)
In savefig (line 84)
In saveasfig (line 6)
In saveas (line 140)
In filemenufcn>localSaveExportHelper (line 216)
In filemenufcn>localSaveExport (line 344)
In filemenufcn (line 56)
In filemenufcn>localSave (line 186)
In filemenufcn (line 54)

回答(1 个)

Vedant Shah
Vedant Shah 2025-3-12
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:
  1. Open the Scope block and navigate to Settings.
  2. Go to the Logging tab.
  3. Enable Log data to workspace.
  4. 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'))

类别

Help CenterFile Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by