How to store info to 'handles' in a local function in GUIDE?

조회 수: 2 (최근 30일)
jmp448
jmp448 2016년 6월 10일
댓글: jmp448 2016년 6월 10일
I have a GUI file I created using GUIDE, and within it there are the built in callbacks but I also want to create some of my own local functions. With these functions I'd like to be able to both access and store the handles structure that contains basically all the info for my GUI, but I am doing something wrong and just cannot figure out what it is. I believe I should be able to feed hObject, eventdata, and handles into the function, load in guidata, and store it using guidata(hObject, handles) - or at least that's what I got from the site about 'guidata'. I made a super simple code to look into this and still couldn't figure it out, so please tell me what I'm doing wrong. Thanks for the help.
function Problem(hObject, eventdata, handles)
guidata(hObject);
handles.NewValue = 5;
guidata(hObject,handles);
Now it's my understanding that after this subfunction is called, from there on out I should be able to access handles.NewValue, which has '5' stored as its value. Is this correct?
  댓글 수: 1
jmp448
jmp448 2016년 6월 10일
Maybe it's an issue with my calling of the function? I thought that if I had this stretch of code anywhere in my script, I should be able to include the lines
Problem(hObject,eventdata,handles);
handles.NewValue
and it would display the NewValue of 5

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

답변 (1개)

TastyPastry
TastyPastry 2016년 6월 10일
Try changing the single input call of guidata() to
handles = guidata(hObject);

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by