How does an m-file output appear in GUI axis?

1 view (last 30 days)
Sue
Sue on 4 Jul 2011
I have an m-file that is executed by a pushbutton in a GUI. It extracts a number of jpeg images and averages them together. The final image is displayed in another figure window. How do I get the result to not appear in another figure window but an axis that is within the GUI interface?

Answers (3)

Jan
Jan on 4 Jul 2011
You can store the handle of the AXES object in the guidata. See "help guidata". Then you can use this handle for creating the new image.

Paulo Silva
Paulo Silva on 4 Jul 2011
In your GUI tag the axes you want to be used
set(gca,'Tag','SueGUIAxes')
Wherever you want to execute the code to show the results do this
axes(findall(0,'Tag','SueGUIAxes')) %set the axes as the current ones
%draw the image
Setting the axes to the current one might not work so it's better to give the handle for the axes to the function that plots/draws the image.
Example, if you want to plot on your GUI axes do this:
plot(findall(0,'Tag','SueGUIAxes'),1,1,'*')
Last step: In the GUIDE layout click on the background of the GUI with your mouse right button, choose GUI Options, now change the command line accessibility to ON, now my solution of tagging the axes works just fine.
It works while the GUI is open and the axes tagged so you can do that plot even in the command line or any m-file.
  6 Comments
Paulo Silva
Paulo Silva on 5 Jul 2011
Calling the m-file by name or having the m-file code in your GUI is almost the same thing except in terms of memory zones and other small details. Remove the line where you call the m-file by it's name and paste the m-file code to the same line.
That's weird, how do you insert the image on the axes?

Sign in to comment.


Gerd
Gerd on 5 Jul 2011
Hi Sue, as Paulo stated it looks like you cannot select the axes with the imagesc command.
A workaround might be to use
im = imagesc(uint8(T_mean)), colormap gray
% get current figure handle
your_fig = gcf;
% copy the image to your axes in the GUI
copyobj(im,handles.youraxes)
%Close the im figure
close(your_fig);
Gerd
  5 Comments
Sue
Sue on 18 Jul 2011
Am still getting the above error message. You suggested adding the handles structure (which is result_axes - the 'tag' yes) to the function call? What is the 'function call'? And also to the function prototype of my m-file. What is a 'function prototype'?
Sorry for my lack of knowledge :-/
Sue x

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!