GUI handles problem

8 vues (au cours des 30 derniers jours)
Jason
Jason le 22 Fév 2011
I have a GUI created in Guide where I create for axes (axes 1..axes4).
I want to plot data on these axes from another function defined in a seperate .m file. I thought I only hat to include "handles" as an argument to pass. In my seperate function where I want to plot to these axes, I use:
axes(handles.axes1)
plot(X,Y)
But I get an error
??? Error using ==> axes
Invalid object handle
Any suggestions to what I am doing wrong Thanks. Jason

Réponse acceptée

Jason
Jason le 22 Fév 2011
Hi Matt. I am using the GUIDE interface to select a certain image. I also include an axes component from the GUIDE palette. I tehn run a seperate m file to perform image analysis and this calculates certain properties of the image i.e. average FWHM and SNR etc. I then want to take these values and plot them on the original axes component I created in GUIDE.
I have searched the net for a day and thought you only have to pass the handles structure as an argument. Once this is done, I can then access the AXES component and plot to it by:
axes(handles.axes1) //select component to plot to
plot(X,Y) //plot to it
Seems like Im missing something and am at a loss!
  6 commentaires
Walter Roberson
Walter Roberson le 22 Fév 2011
Jason, sounds like you might have had "hold on" on the axes.
I suggest, by the way, using this approach:
ax = handles.axes1;
plot(ax, s(a,1),s(a,3)/1000,'k.');
without using axes() to make the axes the "current" axes. I recommend this approach of explicitly specifying the axes in the call because there are circumstances under which the "current axes" can change unexpectedly... especially while you are debugging.
Jason
Jason le 22 Fév 2011
Walter - you are a star, thats exactly the problem, I did have hold on. Thankyou very much and for the advice over handles.axes1.

Connectez-vous pour commenter.

Plus de réponses (1)

Matt Tearle
Matt Tearle le 22 Fév 2011
It sounds like you're trying to refer to a local variable in a separate function. The GUI function created by GUIDE contains the structure variable handles, with a field called axis1. You need to pass that variable to your plotting function when you call it, but you have to do so from within the main GUI function, otherwise it won't recognize the variable. How is your plotting function being invoked? The typical way in a GUI is that some interaction with the GUI invokes a callback. GUIDE callbacks take three arguments by default, the second being the handles structure.

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by