Urgent, help please (probably very easy solution but i couldn't get)
1 view (last 30 days)
Show older comments
I have 2 gui files, one is the main, and the other is running in the opening function of the main gui as a question popup in order to take an input for the usage in the main function. After this, it closes. And when i push the stop button in my main Gui file, getappdata command in this push button callback function does not work, as you can see the "current" value gives nothing to the screen of Matlab. For testing, i type getappdata(0,'current') in the Matlab command window, i can see, but when i press the push button, i cannot see, whatever the problem is, i couldn't get, can anyone help me please?
function stopbutton_Callback(hObject, eventdata, handles)
% hObject handle to stopbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%t=toc;
current = getappdata(0, 'current') ;
current
global timerx;
timery = timerx;
stop(timery)
t = 0;
formttt='%d%d:%0.2f';
t=datevec(t/86400);
s=strrep(sprintf(formttt,t),': ',':0');
global zamanx;
1 Comment
Walter Roberson
on 27 Feb 2012
http://www.mathworks.com/matlabcentral/answers/29922-why-your-question-is-not-urgent-or-an-emergency
Answers (4)
Walter Roberson
on 11 Feb 2012
What does
getappdata(0)
report at that point?
Are you sure you do not have an rmappdata() somewhere?
2 Comments
Walter Roberson
on 11 Feb 2012
I am not saying that you _do_ have it, or that you _should_ have it: I am asking you to check whether you have it, as it would be one mechanism by which the appdata could disappear.
Please check getappdata(0) at the end of the opening function, and then after the opening function but before pressing the stop button, and then again within the stop callback.
Image Analyst
on 11 Feb 2012
Obviously there's a lot of code omitted - for example your stop code has a lot of useless stuff that it's probably only partially listed. But I'm wondering why you think "current" should have anything at all in it. Was there code in your OpenFcn() file that loaded something into "current"? That's what Walter was hinting at. Run the code he gave and you'll probably not see current listed, meaning that you never called setappdata() to load anything into it in the first place. Unless you omitted that code, I see no reason why current should be anything other than null.
5 Comments
Image Analyst
on 11 Feb 2012
I thought 1 was the handle of MATLAB, like fprintf(1, '%s'..... and that 0 was the handle of the active GUI. No? You're probably right. I tried to find in the help where predefined handles numbers (like 0 and 1) are discussed but couldn't find it. Say where if you know where. I always refer to my GUIs by their handle variable rather than some predefined number.
Walter Roberson
on 27 Feb 2012
0 is the handle of the "root" of the graphics system. No other handle numbers are pre-defined for graphics. The handle of the active GUI is returned by gcf(), with gca() and gcbo() being important calls related to the object system.
When it comes to I/O, file identifiers (not handles) 0, 1, and 2 are pre-defined. 0 is defined for standard input, 1 for standard output, and 2 for standard error. In practice standard error and standard output go to the same place but standard error (2) is unbuffered whereas standard output (1) is buffered.
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!