How to recall a figure which was generated by a name "fname = figure; figure(fname)" without saving it ?

조회 수: 16 (최근 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

답변 (1개)

Fangjun Jiang
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
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 CenterFile 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!

Translated by