Handling axes as arguments

조회 수: 17(최근 30일)
Ria3242 2016년 5월 4일
댓글: Mike Garrity 2016년 5월 4일
Help needed...
In my GUI, there are 5 axes, one displays a grid of images, and the others display the cropped images from the grid having one cropped image from mouse input to be displayed on one axis in a sequence i.e. an image password of having four sub-images will be formed further. At first I was setting the new axis for the next cropped image by handling it in a loop. There were warnings regarding speed. Then I passed the handles in arguments as:
a2 = axes(handles.axes2);
a3 = axes(handles.axes3);
a4 = axes(handles.axes4);
a5= axes(handles.axes5);
before my loop started. and within the loop I ploted where I wanted:
switch password_count
case 0
plot (a2);
password_array(1)=temp_im; %#ok
case 1
plot (a3);
password_array(2)=temp_im; %#ok
case 2
plot (a4);
password_array(3)=temp_im; %#ok
case 3
plot (a5);
password_array(4)=temp_im; %#ok
now it gives me these errors:
Error using axes Too many output arguments.
Error in a2 = axes(handles.axes2);
Thanks in advance!


Mike Garrity
Mike Garrity 2016년 5월 4일
Axes only returns an axes handle in the cases where it is creating an axes object. The syntax where you pass an axes handle in is different. In that case, it's not creating an axes, it's just setting gca. It sounds like you probably want something like this instead.
a2 = handles.axes;
Alternatively, you could skip the call to axes entirely. It looks like you're going to pass the axes handle into your plotting function. Therefore you really don't need to make it gca. But making it gca does have the nice side effect of making sure that the figure is in front of other windows.
  댓글 수: 2
Mike Garrity
Mike Garrity 2016년 5월 4일
I'm afraid I don't know the history of that one. I'm afraid that it goes way, way back.
We have been on a bit of a kick of making things more uniform lately. Perhaps this one should be on the todo list.

댓글을 달려면 로그인하십시오.


Community Treasure Hunt

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

Start Hunting!

Translated by