matlab GUIs: calling one GUI from another GUI

3 visualizaciones (últimos 30 días)
ammara AMMARA
ammara AMMARA el 30 de Abr. de 2012
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.

Respuestas (1)

Jan
Jan el 30 de Abr. de 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.

Categorías

Más información sobre Scope Variables and Generate Names en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by