필터 지우기
필터 지우기

Guide Question

조회 수: 1 (최근 30일)
Melvin
Melvin 2012년 3월 7일
Here is the case using GUIDE. I have a pop-up menu with 5 choices(A B C D & E). I also have a push button that do some stuffs. If I run the GUI,I will first choose from the 5 in the pop up menu. Each choice uploads a .mat file in which I retrieve the variable such that:
fullFileName = fullfile(folder, baseFileName)
storedStructure = load(fullFileName);
x = storedStructure.x;
y = storedStructure.y;
Now, when I click that push button I want that push button to retrieve or use x and y for some stuffs directly from the pop up menu function. What code should I write under the callback function of the push button so that that push button will be able to get or retrieve x and y?
If there is something you don't understand in my query just feel free to ask. Thank you very much

채택된 답변

Jan
Jan 2012년 3월 7일
You can store the values of x and y in the handles struct:
handles = guidata(popupMenuHandle);
fullFileName = fullfile(folder, baseFileName)
storedStructure = load(fullFileName);
handles.x = storedStructure.x;
handles.y = storedStructure.y;
guidata(popupMenuHandle, handles);
Then in the callback of the button:
handles = guidata(buttonHandle);
plot(handles.x, handles.y);
Other methods:
  • You can store the data in the UserData of the figure
  • or by setappdata and getappdata, but this is what happens internalöly in guidata also.
  댓글 수: 2
Melvin
Melvin 2012년 3월 7일
Thank you sir :)
Melvin
Melvin 2012년 3월 7일
I have another question.
Are the codes popupMenuHandle and buttonHandle called tags?
I don't get these part exactly,
handles = guidata(popupMenuHandle);
guidata(popupMenuHandle, handles);
handles = guidata(buttonHandle);
Thank you in advance sir. :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by