How to recall a figure which was generated by a name "fname = figure; figure(fname)" without saving it ?
8 次查看(过去 30 天)
显示 更早的评论
Hi,
I have many figures and for validation purpouse, I have a file1.m file which generate many figures. I clean the worskspace without closing figures and I run file2.m. I want to have the results of file2 to be put on those of file1. This is straightforward when you use figure(1),...,figure(100). However, I have many figures and rather than remembering the correspondance between the variables to be plot and the figure numbers, I want to have something like this:
fpressure = figure; figure(fpressure);
ftemperature = figure;figure(ftemperature)
This works perfectly within one file. As soon as I use clear command, it is forgotten which figure was fpressure and ftemperature. So the file2's plots wont be on those have been generated before. Is there any mean to do what I want to do ?
Regards,
Mary
0 个评论
回答(1 个)
Fangjun Jiang
2020-5-28
编辑:Fangjun Jiang
2020-5-28
When you run fpressure=figure, it creates the figure object handle fpressure. But after you clear the workspace, the figure object handle is gone although the figure window still exists. You can "find" those figure obejct handles but won't be able to match by figure object handle name. I suggest you add some keywords to be able to find it later.
close all; clear all;
fpressure=figure;ftemperature=figure;
clear;
f=findall(0,'type','figure')
close all; clear all;
fpressure=figure('name','pressure');
ftemperature=figure('name','temperature')
clear
fpressure=findall(0,'type','figure','name','pressure')
5 个评论
Fangjun Jiang
2020-6-10
编辑:Fangjun Jiang
2020-6-10
Please read it again. In the first section, I was trying to explain that you could find the figure but couldn't tell which one is which because there is no keyword (or anything to identify the figure).
In the second section, you can find and match.
If you ran both section of the code, there are two figures left. The two created in the first section were closed by "close all".
The solution is in the second section, if you could understand it.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!