matlab GUIs: calling one GUI from another GUI

2 ビュー (過去 30 日間)
ammara AMMARA
ammara AMMARA 2012 年 4 月 30 日
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.

回答 (1 件)

Jan
Jan 2012 年 4 月 30 日
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.

カテゴリ

Help Center および File ExchangeScope Variables and Generate Names についてさらに検索

タグ


Translated by