matlab GUIs: calling one GUI from another GUI
1 view (last 30 days)
Show older comments
after going through doug's video tutorial about calling one gui from another gui, i tried doing the same and included these lines in the opening function of my gui:
setappdata(0, 'hMainGui', gcf);
setappdata(gcf, 'fhpointofinter', @pointofinter);
'pointofinter' is a function in main gui.
the code i included in the 'pointofinter' function is:
hMainGui=getappdata(0, 'hMainGui');
..................
intersection=getappdata(hMainGui, 'intersection');
findobj(hMainGui, 'type', 'edit9');
where the value in edit9 is to be fed into second gui.
in the second gui i included the code below:
hMainGui=getappdata(0, 'hMainGui');
fhpointofinter=getappdata(hMainGui, 'fhpointofinter');
intersection=get(hObject, 'Value');
setappdata(hMainGui, 'intersection', intersection);
getappdata(hMainGui, 'intersection');
feval(fhpointofinter);
i am able to call first gui from second gui but im unablee to pass the value in edit9 from first gui to second gui. im getting the following error:
Error using ==> feval
Undefined function or variable 'pointofinter'.
feval(fhpointofinter);
can anyone explain to me what the problem is.
0 Comments
Answers (1)
Jan
on 30 Apr 2012
It is surprising, that the error message contains "variable 'pointofinter'", although this variable has not been used anywhere in the posted code. I guess, that you overwrite the store function handle by the string 'pointerofinter' by accident anywhere.
Storing values in the global root object is equivalent to using global variables. This is hard to debug, because the values can be changed from anywhere. I'd prefer using a function, which stores the variables (here the function pointer) persistently. Then setting a breakpoint in this function allows to track, who is changing the value.
0 Comments
See Also
Categories
Find more on Migrate GUIDE Apps 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!