Use of Position property of figures

2 ビュー (過去 30 日間)
Luca Tarasi
Luca Tarasi 2019 年 9 月 15 日
コメント済み: Luca Tarasi 2019 年 9 月 16 日
Hi,
in the Command Window, when I execute the following as a single command
>> f = figure(1);plot(0);disp(f.Position);f.WindowState = 'maximized';disp(f.Position);
the printed outputs is
403 246 560 420
403 246 560 420
However, when I execute it as two separate commands,
>> f = figure(1);plot(0);disp(f.Position);f.WindowState = 'maximized';
and
>> disp(f.Position);
I get, respectively, the following two outputs:
403 246 560 420
1 41 1366 651
The second output is different (as I expected it to be). Why are the outputs different only when running the commands separately?
Thank you,
LT.

回答 (1 件)

Ankit
Ankit 2019 年 9 月 16 日
Hi Luca,
using this command you can get the default figure position using get command
for e.g.
>> f = figure(1);plot(0);a = get(f,'defaultfigureposition');
a is in your case is the first output
later using f.WindowState = 'maximized'; you are changing the state from 'normal' to 'maximizied'
And displaying the changed position. This is your second output.
I would recommend you to use following command:
This will display the all the properties specific to the figure.
I hope this helps.
Thanks
Ankit
  1 件のコメント
Luca Tarasi
Luca Tarasi 2019 年 9 月 16 日
Thank you, but what was unclear to me is why the position is not updated when I run the whole thing as a single command (I've edited the e question to make it less ambiguous).

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

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by