How can I give a figure both a name and a number?

102 ビュー (過去 30 日間)
Felix Crazzolara
Felix Crazzolara 2020 年 4 月 26 日
編集済み: 也 王 2023 年 9 月 16 日
In my program I have a lot of windows and when working on it then I redraw the plots. Also I switch a lot between scripts which generate plots. What I would like to have is that say a specific script always uses a figure associated with a specifc number. In addition to that I want to figure to have title similarly as when we use figure('Name','Name of the figure'). How can I do that?
My MATLAB version is R2019b.

採用された回答

Sriram Tadavarty
Sriram Tadavarty 2020 年 4 月 26 日
Hi Felix,
You can do that by using Name-Value pairs options of figure. You can even look at the examples provided in that page, the first example is what you are looking for.
Hope this helps.
Regards,
Sriram
  4 件のコメント
Felix Crazzolara
Felix Crazzolara 2020 年 4 月 26 日
Ah I got it. The returned figure object has field called Number.
Walter Roberson
Walter Roberson 2020 年 4 月 26 日
fig_handle = figure('Name','Hello')
fig_num = fig_handle.Number
However, in some cases figures are generated that do not have an integer figure number, and when that happens, the Number property is usually empty. You can find the actual figure number in such cases by using
fig_num = double(fig_handle)
These days it is advised that you do not use figure numbers: just record the handles returned by figure() and pass those around.

サインインしてコメントする。

その他の回答 (1 件)

也 王
也 王 2023 年 9 月 16 日
編集済み: 也 王 2023 年 9 月 16 日
fig_handle = figure( 20 );
fig_handle.Name = 'Fig name';

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by