How to modify the handles structure (GUI) from an external function
이전 댓글 표시
Hi,
I am developing a GUI. I can modify the handles structure (for example handles.variable1 = 2) within callbacks. However I am not able to do the same within an external function. E.g., this does not work:
function [matrix, indexVector] = myFunction(handles)
handles.variable1 = 1;
It is important to note that myFunction does not belong to the GUI callbacks, it is simply a function I have created in another m file. When I call it I can read the handles struture (actually im passing them as a parameter) but when I try to modify them the modification is not recorded.
Best,
-MRR
채택된 답변
추가 답변 (3개)
Azzi Abdelmalek
2013년 3월 8일
Use
function [matrix, indexVector] = myFunction(hObject,handles)
handles.variable1 = 1;
guidata(hObject,handles)
댓글 수: 4
Jan
2013년 3월 19일
@MRR: I disagree: The shown code does save the modified struct handles in the GUI, as long as you provide a handle of any object inside the GUI as hObject. So please explain with details, why you assume, that this method does not work and see my comment to Sean's answer.
MRR
2013년 3월 20일
Azzi Abdelmalek
2013년 3월 20일
MRR, if so then accept his answer
QiQin Zhan
2013년 3월 8일
0 개 추천
I suggest using the function handles.
zakaria
2014년 6월 5일
handles = guihandles(gcbo); % if not presents in the other external function
카테고리
도움말 센터 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!