MatLab returns false figure size in script

1 回表示 (過去 30 日間)
Tobias Fink
Tobias Fink 2020 年 7 月 21 日
コメント済み: Tobias Fink 2020 年 7 月 21 日
Hello,
I'm using the following script. If I run each line individually, it gives the right Position so I can get the Width and Height of the figure. But when I use it in a script it keeps giving me the position from before maximizing it.
When asking for the Position after running the script, it gives the right Position too.
is there any way I can resolve that problem?
%% Creating GUI
GUI=uifigure('Name','Spectrograms',...
'NumberTitle','off',...
'WindowState','maximized');
% get window size
Position=get(GUI, 'Position');
GUI_Width=Position(3);
GUI_Height=Position(4);
  1 件のコメント
Walter Roberson
Walter Roberson 2020 年 7 月 21 日
The uifigure does not exist before you create it so I am not sure what value from "before" you maximized it that you are referring to?

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

採用された回答

Arthur Roué
Arthur Roué 2020 年 7 月 21 日
Add a call to drawnow after creating the figure
%% Creating GUI
GUI=uifigure('Name','Spectrograms',...
'NumberTitle','off',...
'WindowState','maximized');
% Update figures and process callbacks
drawnow;
% get window size
Position=get(GUI, 'Position');
GUI_Width=Position(3);
GUI_Height=Position(4);
  1 件のコメント
Tobias Fink
Tobias Fink 2020 年 7 月 21 日
Thank you so much! :)

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by