I'm trying to change panel and axes width and height values by using user input. These values will represent a photograph's resolution. For example, if a user inputs 512*512
, the uipanel
and Axes
' width and height will change to 512
and the user will work on this workspace.
What I tried so far:
prompt = {'Enter width', 'Enter height'};
dlg_title = 'Input'; num_lines = 1; def = {'256','256'};
answer = inputdlg(prompt,dlg_title,num_lines,def);
uipanel1.width = str2num(answer{1});
uipanel1.height = str2num(answer{2});
but the size of uipanel1
does not change.
Here's code that demonstrates how what you want can be done, which works with matlab-hg2 (default from MATLAB 2014b and onward).
On older versions of MATLAB, you may need slightly different steps: