MATLAB Answers

Naz
0

How to keep the size aspect ratio of GUI form fixed?

Asked by Naz
on 18 Oct 2011

Hi all. I am trying to make my GUI figure to be resizable but I need the aspect ratio to be fixed. Is this possible to achieve?

  0 Comments

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson
on 18 Oct 2011

You can put in a resize callback on the figure that changes the size to match the aspect ratio you want.

  2 Comments

My GUI figure is called 'Vessel' and here is a code I provide for it:

function Vessel_Callback(hObject, eventdata, handles)
[x y w h]=get(hObject,'Position')
w=(4*h)/3;
set(hObject,'Position',[x y w h])

So far, it does not seem to work

Walter, can you give me a more explicit suggestion?


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!