MatLab returns false figure size in script

1 Ansicht (letzte 30 Tage)
Tobias Fink
Tobias Fink am 21 Jul. 2020
Kommentiert: Tobias Fink am 21 Jul. 2020
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 Kommentar
Walter Roberson
Walter Roberson am 21 Jul. 2020
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?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Arthur Roué
Arthur Roué am 21 Jul. 2020
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);

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by