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

24 ビュー (過去 30 日間)
mary
mary 2020 年 5 月 28 日
編集済み: Fangjun Jiang 2020 年 6 月 10 日
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 件のコメント
Mary
Mary 2020 年 6 月 10 日
No, the solution one generates 4 figures.
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 Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by