From: Dave ba on 8 Apr 2010 14:41 How can you make a vector global and local?
From: dpb on 8 Apr 2010 16:44 Dave ba wrote: > How can you make a vector global and local? Global is global... :) Don't think this is the question you're really intending to ask, Dave... Try here... <http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/f5-998352.html> There is significantly more documentation/help in R2009 on the subject than available in mine; I just hadn't looked online bcuz my dialup connection is quite slow. But, this spurred me 'cuz didn't think it was getting where you wanted to go. --
From: Dave ba on 9 Apr 2010 03:10 dpb <none(a)non.net> wrote in message <hplfba$80r$1(a)news.eternal-september.org>... > Dave ba wrote: > > How can you make a vector global and local? > > Global is global... :) > > Don't think this is the question you're really intending to ask, Dave... > > Try here... > > <http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/f5-998352.html> > > There is significantly more documentation/help in R2009 on the subject > than available in mine; I just hadn't looked online bcuz my dialup > connection is quite slow. But, this spurred me 'cuz didn't think it was > getting where you wanted to go. > > -- you were right, in the helpdesk is says, setappdata: Specify named application data for an object (a figure or other Handle Graphics object in your GUI). You can specify more than one named application data for an object. However, each name must be unique for that object and can be associated with only one value, usually a structure. 'only one value'. (although it seems that it can store my t vector...) so I cant use global and local, so the actual question must be: How can I store a vector with guide? or even more specifically how can I convert this code: function mygui_OpeningFcn(hObject, eventdata, handles, varargin) matrices.rand_35 = randn(35); setappdata(hObject,'mydata',matrices); function mygui_pushbutton1(hObject, eventdata, handles) matrices = getappdata(handles.figure1,'mydata'); matrices.randn_50 = randn(50); setappdata(handles.figure1,'mydata',matrices); to my situation, where Y(1,t) must be created, in the callback of pushbutton2 then stored. then taken back in the callback of pushbutton3 setting the value of Zy in the place of Y(1,bnr) and then updated and stored. and at last taken back in the callback of pushbutton7 to be plotted. something like this?: %in the callback of pushbutton2 function mygui_pushbutton2(hObject, eventdata, handles, varargin) Y(1,t) = 0; setappdata(hObject,'mydata',Y); %in the callback of pushbutton3 function mygui_pushbutton3(hObject, eventdata, handles) Y = getappdata(handles.figure1,'mydata'); Y(1,bnr) = Zy; setappdata(handles.figure1,'mydata',Y); %in the callback of pushbutton7 function mygui_pushbutton7(hObject, eventdata, handles) Y = getappdata(handles.figure1,'mydata'); ok, when I try that it doesnt even seem to load the video file...
From: dpb on 9 Apr 2010 09:34 Dave ba wrote: > dpb <none(a)non.net> wrote in message > <hplfba$80r$1(a)news.eternal-september.org>... >> Dave ba wrote: >> > How can you make a vector global and local? >> >> Global is global... :) >> >> Don't think this is the question you're really intending to ask, Dave... >> >> Try here... >> >> <http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/f5-998352.html> >> >> >> There is significantly more documentation/help in R2009 on the subject >> than available in mine; I just hadn't looked online bcuz my dialup >> connection is quite slow. But, this spurred me 'cuz didn't think it >> was getting where you wanted to go. >> >> -- > > you were right, > in the helpdesk is says, > setappdata: > Specify named application data for an object (a figure or other Handle > Graphics object in your GUI). You can specify more than one named > application data for an object. However, each name must be unique for > that object and can be associated with only one value, usually a structure. > > 'only one value'. > (although it seems that it can store my t vector...) > > so I cant use global and local, so the actual question must be: > How can I store a vector with guide? .... I'm not positive about the global thing... I'd think if you made data global it would be visible but perhaps there's something about callback functions' scoping rules I'm not aware of having never used them in ML... Reading the GUIDE doc's for R2009, it seems that perhaps what you're looking for would be to restructure using nested functions. I was sure I read somewhere when I looked the other day about an array w/ GUI but I couldn't seem to find that this morning. All I can say is it only further reinforces my intention to stay away from GUIs in Matlab... :) Although surely there is a way, it does seem terribly convoluted and difficult to piece toghether through the documentation altho again I'm sure it (the documentation, that is) is perfectly clear and seems complete to those who wrote it who are insiders... I think the question you need to ask is the one you finally got to above but perhaps even a little more generically as to how is one generally supposed to structure large data other than individual named tag variables in GUIs under Matlab? As with you, it's certainly not clear to me from an hour or so of reading documentation and the examples seem to have been constructed without the issue being raised. Sorry, but I'm at (actually well past) end of my knowledge--I had thought from the appdata description in my version any ML variable was associated/retrieved not the limitation of a single value that the recent documentation makes clear. --
From: Dave ba on 9 Apr 2010 13:48
dpb, It is finally working!! I did got help from my mentor. with the code of the thread: Plotting gone wrong. (message 12) first push button: Y=zeros(1,t); instead of: Y=zeros(1,length(t)); <-- because with this one it says how many value's a variable has, instead of using the real value. this time the value of t was 32, but with 'length' it says 32 is only 1 number, so it gets the value 1. setappdata(gcf,'Y',Y) second push button: t = getappdata(gcf,'t'); t1 = 1:1:t; setappdata(gcf,'t1',t1) bnr = getappdata(gcf,'bnr'); Zy = getappdata(gcf,'Zy'); Y = getappdata(gcf,'Y'); <-- if it was Y(1,t) =... it gets erased again. You were right that whole time. Y(1,bnr)= Zy; setappdata(gcf,'Y',Y) so now under the plot button I have: t1 = getappdata(gcf,'t1'); Y = getappdata(gcf,'Y'); plot(handles.axes2,t1,Y) thanks again dpb, you've helped me this whole time. even though you say you dont use guide, I would put guide-master behind your name if it was up to me. |