Saving graphs while preserving all their characteristics
3 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I have this problem. Whenever I generate a plot using the "step" or "bode" commands for example and I save the figure, the next time I try to open it, all the characteristics are lost (like "peak response", "settling time", etc). So, I'm forced to do another "step" or "bode" plot. How do I save a plot while preserving all the characteristics?
I appreciate your help in advance.
e.
2 个评论
Zachary
2020-8-3
编辑:Zachary
2020-8-3
+1 this question! I have never been able to share the rich interactive figures (i.e. the context menus) generated by the Control System Toolbox. I always have to share the script that generates the figure instead. Sometimes this is impractical.
Here is an example of the problem...
%Generate a response plot
fh = figure; %figure handle
ph = bodeplot(rss(1)); %resppack.bodeplot handle
savefig runs successfully on the figure handle, but I lose the the context menu and the resppack.bodeplot object.
savefig(fh) %only saves graphics
savefig errors on the bodeplot handle because ph isn't a figure handle.
savefig(ph) %errors
save runs with a warning because I should be using savefig for a figure. When loading fh or ph, I get stuck in an endless loop of listener warnings and the figure window opens multiple times (all of which lack context menus).
save myfile.mat fh ph %warning to use savefig instead
load myfile.mat fh %endless loop of warnings
load myfile.mat ph %endless loop of warnings
回答(1 个)
Image Analyst
2012-3-11
You might want to have a variable, a structure, called something like GraphSettings. Then you could save all the parameters in a single variable and then save it to a mat file and recall it easily. Like
GraphSettings.peakResponse = 42;
GraphSettings.settlingTime = 10;
GraphSettings.LineWidth = 2;
GraphSettings.LineColor= 'r';
% To save:
save('myAppsSettings.mat', 'GraphSettings');
% To recall
s = load('myAppsSettings.mat');
GraphSettings = s.GraphSettings;
Then you use GraphSettings to rebuild your graph. You might want to have a function called something like "BuildGraph" that does everything necessary to build your graph from the data and the other settings saved in GraphSettings.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Control System Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!