Thread Subject: function running within a GUI

Subject: function running within a GUI

From: Michael Ashby

Date: 1 Feb, 2010 17:55:24

Message: 1 of 3

I have a gui (created with GUIDE) that contains a "Go" pushbutton and several axes.
Upon pushbutton down, I want to run a second function that collects some data from an external device and plots that data in the axes within the GUI. I want this plotting to happen while the second function is still running to see the data as it is collected. Depending on when the data is collected, it should be targeted to a specific axes within the GUI.

Not sure I'm going about this the correct way at all but I tried to make the GUI handles variable global in both functions and plot within the second function by making the desired axis current with the approriate axis handle....as follows:

global handles
axes(handles.axes1) % make axes1, for example, current
plot(x, y) %plot in the current axis

....but it seems the handle is not recognized as such when called in the second function, as I get the error

Error using ==> axes
Invalid object handle

Can anyone help me on where I am going wrong with this approach or whether I should use a different tack like nesting the function in the GUI?

Thanks a lot
Mike


  

Subject: function running within a GUI

From: Steven Lord

Date: 1 Feb, 2010 18:17:30

Message: 2 of 3


"Michael Ashby" <ashbymc{removethis}@gmail.com> wrote in message
news:hk74ic$hij$1@fred.mathworks.com...
>I have a gui (created with GUIDE) that contains a "Go" pushbutton and
>several axes.
> Upon pushbutton down, I want to run a second function that collects some
> data from an external device and plots that data in the axes within the
> GUI. I want this plotting to happen while the second function is still
> running to see the data as it is collected. Depending on when the data is
> collected, it should be targeted to a specific axes within the GUI.
> Not sure I'm going about this the correct way at all but I tried to make
> the GUI handles variable global in both functions and plot within the
> second function by making the desired axis current with the approriate
> axis handle....as follows:
>
> global handles
> axes(handles.axes1) % make axes1, for example, current
> plot(x, y) %plot in the current axis
>
> ....but it seems the handle is not recognized as such when called in the
> second function, as I get the error
>
> Error using ==> axes
> Invalid object handle
>
> Can anyone help me on where I am going wrong with this approach or whether
> I should use a different tack like nesting the function in the GUI?

http://www.mathworks.com/support/solutions/en/data/1-1B5UM/?solution=1-1B5UM
http://www.mathworks.com/support/solutions/en/data/1-16DHA2/?solution=1-16DHA2

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: function running within a GUI

From: Michael Ashby

Date: 1 Feb, 2010 19:14:05

Message: 3 of 3

"Steven Lord" <slord@mathworks.com> wrote in message <hk75rg$9su$1@fred.mathworks.com>...
>
> "Michael Ashby" <ashbymc{removethis}@gmail.com> wrote in message
> news:hk74ic$hij$1@fred.mathworks.com...
> >I have a gui (created with GUIDE) that contains a "Go" pushbutton and
> >several axes.
> > Upon pushbutton down, I want to run a second function that collects some
> > data from an external device and plots that data in the axes within the
> > GUI. I want this plotting to happen while the second function is still
> > running to see the data as it is collected. Depending on when the data is
> > collected, it should be targeted to a specific axes within the GUI.
> > Not sure I'm going about this the correct way at all but I tried to make
> > the GUI handles variable global in both functions and plot within the
> > second function by making the desired axis current with the approriate
> > axis handle....as follows:
> >
> > global handles
> > axes(handles.axes1) % make axes1, for example, current
> > plot(x, y) %plot in the current axis
> >
> > ....but it seems the handle is not recognized as such when called in the
> > second function, as I get the error
> >
> > Error using ==> axes
> > Invalid object handle
> >
> > Can anyone help me on where I am going wrong with this approach or whether
> > I should use a different tack like nesting the function in the GUI?
>
> http://www.mathworks.com/support/solutions/en/data/1-1B5UM/?solution=1-1B5UM
> http://www.mathworks.com/support/solutions/en/data/1-16DHA2/?solution=1-16DHA2
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>
Thank you, Steve. Changing the 'NextPlot' axes property to 'ReplaceChildren' seems to smooth things out.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
gui Michael Ashby 1 Feb, 2010 12:59:17
guide Michael Ashby 1 Feb, 2010 12:59:17
global Michael Ashby 1 Feb, 2010 12:59:17
function Michael Ashby 1 Feb, 2010 12:59:17
rssFeed for this Thread

Contact us at files@mathworks.com