matlab GUIs: calling one GUI from another GUI
조회 수: 3 (최근 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.
댓글 수: 0
답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!