From: Matt Fig on 28 May 2010 16:19 Wherever the string is returned from uigetfile, save it using guidata or something similar. Then in your start button callback, access the string. % in menuitem callback STR = uigetfile(...) HC = guidata(gcbf); HC.STR = STR; guidata(gcbf,HC) % Now in your start button callback HC = guidata(gcbf) STR = HC.STR; % This is the string returned by gui
From: Steven Lord on 28 May 2010 16:33 "Adam " <abc5(a)ubc.ca> wrote in message news:htp1j5$dkb$1(a)fred.mathworks.com... > "Steven Lord" <slord(a)mathworks.com> wrote in message > <htov5a$aq0$1(a)fred.mathworks.com>... *snip* > What I meant by is open, is simply that it does not end. I'm having > numerous errors when ending the callbacks. What happens is, if I end each > callback, function varargout also requires a callback. If I end varargout, > it runs, but gives a list of errors as shown below (there's more- this is > a sample). Essentially, I am ending the Guide Generated Code in this case. I think we may be experiencing the problem where "end" is being overloaded and it's ambiguous which overload is being used [and I'm not talking about the MATLAB keyword but the English word here.] Can you show one of your shorter callback functions that "does not end", and explain in a bit more depth what you're actually doing when you "ending the callbacks" or "end varargout"? Anyway, for sharing data among callbacks, I recommend you look at one of the techniques (like using the UserData property or the handles structure) described on that documentation page to which I linked in my previous message. -- 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: Adam on 28 May 2010 16:34 Thanks, I appreciate the help. Unfortunately, this also didn't work since my functions are within the GUI. I think I'm doing a bad job of explaining my question. Here is some code from my GUI that may help illustrate my question. I created the GUI in Guide with some menus (so far: just file and help). Since this is an optimization tool, one option will be to import objectives equations from a separate file. To do this, I've created a menu option called import_objectives. The callback is below: function import_objectives_Callback(hObject, eventdata, handles) objectivesfName=uigetfile('*.txt','Select the Text-file Containing the Objectives Functions'); This returns the file name to a string which I would like to later use in another callback (the start button). And then use this name to read a file. function startButton_Callback(hObject, eventdata, handles, objectivesfName) objFuncs = textread(objectivesfName,'%s'); The problem is when this runs objectivesfName doesn't exist in startButton_Callback, even its made global since. So, I was wondering if I could create some kind of variable/handle/object either within import_objectives_callback or outside of it that allow me to access it in startButton_Callback. Thanks a lot for the responses so far. I've tried them but can't figure it out :(. What is the best way to do this?
From: Steven Lord on 28 May 2010 16:37 "Walter Roberson" <roberson(a)hushmail.com> wrote in message news:ZgTLn.22588$Gx2.19637(a)newsfe20.iad... > Steven Lord wrote: >> Any function in a file that contains a nested function must end with an >> END, and each such function will end at its corresponding END; functions >> in a file that does not contain a nested function should not end with >> END, but will end at the start of the next function or at the end of the >> file. > > Steve, is there reason to avoid using END when there is no nested > function? Off the top of my head, I can't think of one. [Because I wrote this, I give it half an hour before someone stops by my office and reminds me of such a reason :] If you're writing a new file and you start out ENDing all the functions I don't think it would hurt anything. But remember, if you have a file that contains hundreds or thousands of functions that do not end with END, and you introduce _one_ new function that does, you have to go back to _all_ of the functions in the file and insert the END. -- 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: Adam on 28 May 2010 16:41 "Steven Lord" <slord(a)mathworks.com> wrote in message <htp9ic$95b$1(a)fred.mathworks.com>... > > "Walter Roberson" <roberson(a)hushmail.com> wrote in message > news:ZgTLn.22588$Gx2.19637(a)newsfe20.iad... > > Steven Lord wrote: > >> Any function in a file that contains a nested function must end with an > >> END, and each such function will end at its corresponding END; functions > >> in a file that does not contain a nested function should not end with > >> END, but will end at the start of the next function or at the end of the > >> file. > > > > Steve, is there reason to avoid using END when there is no nested > > function? > > Off the top of my head, I can't think of one. [Because I wrote this, I give > it half an hour before someone stops by my office and reminds me of such a > reason :] > > If you're writing a new file and you start out ENDing all the functions I > don't think it would hurt anything. But remember, if you have a file that > contains hundreds or thousands of functions that do not end with END, and > you introduce _one_ new function that does, you have to go back to _all_ of > the functions in the file and insert the END. > > -- > 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 > Good point, I may be missing an 'end' somewhere I'll check to make sure.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: Curve / data fit Next: How large was the largest system that you have simulated in Simulink? |