Prev: Problem with using svmtrain() function
Next: how to read data from serial port using matlab in pc
From: John on 15 Jul 2010 07:08 Hello, I have a GUI plotting multiple axes which all overlay one another to look like one plot on a GUI. I have a "CLEAR" button which I want to clear ALL of the axes and ALL legends inherent to those axes. The axes are referred to as members of an array: handles.data_axes(1) handles.data_axes(2) handles.data_axes(3) handles.data_axes(4) ... and so on. The legends are referred to similarly. The callback for my CLEAR button is: cla(handles.data_axes); legend(handles.data_axes,'off') set(handles.Channel2AnalyzeList,'String',[]) Currently, this only clears the plot on the first axes (which is the axes I initially placed on my GUI in using GUIDE). I would like the CLEAR button to clear ALL axes and legends. Any ideas or new approaches are very appreciated! Thanks!
From: John on 15 Jul 2010 07:58 "John " <jfishbac(a)gmail.com> wrote in message <i1mq6n$ahq$1(a)fred.mathworks.com>... > Hello, > > I have a GUI plotting multiple axes which all overlay one another to look like one plot on a GUI. I have a "CLEAR" button which I want to clear ALL of the axes and ALL legends inherent to those axes. The axes are referred to as members of an array: > > handles.data_axes(1) > handles.data_axes(2) > handles.data_axes(3) > handles.data_axes(4) ... and so on. > > The legends are referred to similarly. > > The callback for my CLEAR button is: > cla(handles.data_axes); > legend(handles.data_axes,'off') > set(handles.Channel2AnalyzeList,'String',[]) > > Currently, this only clears the plot on the first axes (which is the axes I initially placed on my GUI in using GUIDE). I would like the CLEAR button to clear ALL axes and legends. > > Any ideas or new approaches are very appreciated! Thanks! I think it has something to do with the way I'm using handles. When I created the axes (by using a "PLOT" button in my GUI), I called each one handles.AXES(i). I also called each legend handles.LEGEND(i). So if I have three Axes plotted, i return three handles.AXES handle in the PLOT button callback. BUT!!! When I go to the clear button callback and do some debugging, I only return ONE handles.AXES handle (as opposed to the three that are in existence), and the handles.LEGEND handle is not even recognized. Am I doing something wrong when naming the handles for AXES and LEGEND? Should I create global variables instead?
From: John on 15 Jul 2010 08:11 "John " <jfishbac(a)gmail.com> wrote in message <i1mt4g$ekc$1(a)fred.mathworks.com>... > "John " <jfishbac(a)gmail.com> wrote in message <i1mq6n$ahq$1(a)fred.mathworks.com>... > > Hello, > > > > I have a GUI plotting multiple axes which all overlay one another to look like one plot on a GUI. I have a "CLEAR" button which I want to clear ALL of the axes and ALL legends inherent to those axes. The axes are referred to as members of an array: > > > > handles.data_axes(1) > > handles.data_axes(2) > > handles.data_axes(3) > > handles.data_axes(4) ... and so on. > > > > The legends are referred to similarly. > > > > The callback for my CLEAR button is: > > cla(handles.data_axes); > > legend(handles.data_axes,'off') > > set(handles.Channel2AnalyzeList,'String',[]) > > > > Currently, this only clears the plot on the first axes (which is the axes I initially placed on my GUI in using GUIDE). I would like the CLEAR button to clear ALL axes and legends. > > > > Any ideas or new approaches are very appreciated! Thanks! > > I think it has something to do with the way I'm using handles. When I created the axes (by using a "PLOT" button in my GUI), I called each one handles.AXES(i). I also called each legend handles.LEGEND(i). So if I have three Axes plotted, i return three handles.AXES handle in the PLOT button callback. > > BUT!!! When I go to the clear button callback and do some debugging, I only return ONE handles.AXES handle (as opposed to the three that are in existence), and the handles.LEGEND handle is not even recognized. Am I doing something wrong when naming the handles for AXES and LEGEND? Should I create global variables instead? Okay, I'm continuing to troubleshoot this problem. In my PLOT button callback, I name each axes using handles.AXES(i) and name each legend using handles.LEGEND(i). Then in the CLEAR button call back, I wrote: for i = 1:length(handles.data_axes) cla(handles.data_axes(i)); legend(get(handles.LEGEND(i)),'visible','off') set(handles.Channel2AnalyzeList,'String',[]) end The CLA command clears the first axes, but the code chokes on the LEGEND command. I also get an error which reads: ??? Reference to non-existent field 'LEGEND'. But I thought I specified this in the PLOT button callback!?!?
From: Steven Lord on 15 Jul 2010 09:29 "John " <jfishbac(a)gmail.com> wrote in message news:i1mtso$3a3$1(a)fred.mathworks.com... > "John " <jfishbac(a)gmail.com> wrote in message > <i1mt4g$ekc$1(a)fred.mathworks.com>... >> "John " <jfishbac(a)gmail.com> wrote in message >> <i1mq6n$ahq$1(a)fred.mathworks.com>... *snip* > The CLA command clears the first axes, but the code chokes on the LEGEND > command. I also get an error which reads: > > ??? Reference to non-existent field 'LEGEND'. > > But I thought I specified this in the PLOT button callback!?!? Did you remember to update the "master" copy of the handles structure with your modified version by using GUIDATA? If not, then when the PLOT button callback finishes executing, all the variables in its workspace are destroyed and then the workspace itself is destroyed -- this includes the modified copy of the handles structure that lived in that workspace. Also note that if there's another callback running when the PLOT button callback updates the master copy, the update to the master copy will not propagate automatically down to those callback function workspaces; those callback functions will need to ask for a new copy of the updated master handles structure or they will continue to use the copy they received when they started executing. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: John on 15 Jul 2010 10:15 "Steven Lord" <slord(a)mathworks.com> wrote in message <i1n2gc$rts$1(a)fred.mathworks.com>... > > "John " <jfishbac(a)gmail.com> wrote in message > news:i1mtso$3a3$1(a)fred.mathworks.com... > > "John " <jfishbac(a)gmail.com> wrote in message > > <i1mt4g$ekc$1(a)fred.mathworks.com>... > >> "John " <jfishbac(a)gmail.com> wrote in message > >> <i1mq6n$ahq$1(a)fred.mathworks.com>... > > *snip* > > > The CLA command clears the first axes, but the code chokes on the LEGEND > > command. I also get an error which reads: > > > > ??? Reference to non-existent field 'LEGEND'. > > > > But I thought I specified this in the PLOT button callback!?!? > > Did you remember to update the "master" copy of the handles structure with > your modified version by using GUIDATA? If not, then when the PLOT button > callback finishes executing, all the variables in its workspace are > destroyed and then the workspace itself is destroyed -- this includes the > modified copy of the handles structure that lived in that workspace. > > Also note that if there's another callback running when the PLOT button > callback updates the master copy, the update to the master copy will not > propagate automatically down to those callback function workspaces; those > callback functions will need to ask for a new copy of the updated master > handles structure or they will continue to use the copy they received when > they started executing. > > -- > Steve Lord > slord(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > To contact Technical Support use the Contact Us link on > http://www.mathworks.com > Okay steve I understand what you are saying. I DON'T understand how to used GUIDATA, especially when I have an array of handles. For instance, my handles structure for each axes created in my GUI (using GUIDE) is: handles.PLOTaxes(1) handles.PLOTaxes(2) handles.PLOTaxes(3) handles.PLOTaxes(4) ... and so on. I tried GUIDATA(hObject, handles.PLOTaxes) where hObject is the PLOT button. Should I be using something other than hOBject? Do I need to somehow refer to each element of the handles.PLOTaxes array? Thanks! -John
|
Next
|
Last
Pages: 1 2 Prev: Problem with using svmtrain() function Next: how to read data from serial port using matlab in pc |