GUI with 2 uipanels, second axes not displaying

1 view (last 30 days)
Hi,
I have a GUI with two uipanels. I use a "Next" button on uipanel 1 to hide uipanel 1 and make uipanel 2 visible. I use a "Back" button on uipanel 2 to hide uipanel 2 and make uipanel 1 visible.
On both uipanels, I display an image. While the image on uipanel 1 displays fine, I cannot seem to get the image on uipanel 2 to display. Could someone please identify how to get the image on uipanel 2 to display?
Please find the 3 GUI files attached. Thanks in advance for your time and effort in responding!
  9 Comments
Walter Roberson
Walter Roberson on 4 Apr 2014
If you stop in the routine that creates the GUI, just after the callbacks are created, and at the command line you put an image into the sensor axes, then if you manually make the first panel invisible and the sensor panel visible, then does the image show up?
MechtEngineer
MechtEngineer on 6 Apr 2014
Thanks for the suggestion. I tried this with no difference. I finally found the answer, and have submitted it. I kept reducing the program complexity, and found that the second axes wasn't even displaying when I was plotting it on it's own uipanel with nothing else displaying! Please read my answer for the solution.
Walter Robertson, thanks again for all your troubleshooting suggestions. They were very much appreciated.

Sign in to comment.

Accepted Answer

MechtEngineer
MechtEngineer on 6 Apr 2014
I finally found the problem. I didn't realise that the order in setting properties all at once (all on one line, or with ellipses (...)) is important. The order of setting properties is equivalent to setting the properties separately on a line of their own in the same order . I had assumed that if setting the 'Units' to be 'pixels' and setting the 'Position' on the same line, that MATLAB would interpret the 'Position' values to be in units of 'pixels'. I presume there are some very good reasons for MATLAB to interpret setting in this way (e.g. simplicity - Mathworks does not have to worry about how some settings might affect others when set simultaneously).
My specific error was the above issue for modifying the second axes settings. In declaring all non-default properties on one line using ellipses (...), I declared the 'Position' property with intended units of pixels before the 'Units' property of 'pixels'. The default 'Units' property is 'normalized', between 0 and 1. For my units in the hundreds, I think this meant the axes was plotted (in virtual space) a considerable distance outside the actual GUI area (only values 0 to 1 are observable), which is why the second uipanel was appearing blank.
This raises a second query - why didn't MATLAB warn me I was plotting an axes outside the visible area of the GUI? I have all the default errors and warnings enabled, and I would have thought this would be a useful warning. Is it worth me suggesting this to Mathworks?
So for the original code below:
% Exposed image axes
handles.sensor_axes = axes('Parent', handles.sensorPanel, ...
'Position', [300 50 900 500], ...
'Units', 'pixels', ...
'Visible','on');
I changed it to:
% Exposed image axes
handles.sensor_axes = axes('Parent', handles.sensorPanel, ...
'Units', 'pixels', ...
'Position', [300 50 900 500], ...
'Visible','on');

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!