Function inside GUI don't save modifies to "handles"
이전 댓글 표시
Hi everybody, I'm trying to do my first GUI, but I'm having some problems. Excuse me if my question is a bit stupid.
When I call a function (located inside the same .m file of the main code) I'm not able to modify the handles structure from inside the function.
I've done a very easy code to explain it better:
function pushbutton1_Callback(hObject, eventdata, handles)
handles.A=1;
guidata(hObject, handles);
modify_A(hObject, eventdata, handles)
disp(num2str(handles.A))
%%%%%%%%%%%%
function modify_A(hObject, eventdata, handles)
handles.A=100;
guidata(hObject, handles);
How can i do it?
thank you very much.
댓글 수: 2
Jose abel De la Fuente
2016년 10월 23일
편집: Jose abel De la Fuente
2016년 10월 23일
Hi.
I have one problem seemed, which does not allow me update the handles.
My problem start when I try using the uipushtool and the ClickedCallback. In the handle function I have tried to update the handle of this way:
uipushtool(tbh,'CData',imread('Complementos\Verde.png'),'Separator','off',...
'TooltipString','Your toggle tool',...
'HandleVisibility','off',...
'ClickedCallback',...
{@marcarPunto,handles, cmP,cnP});
function marcarPunto(hObject,event,handles,cmP,cnP)
[handles.pnSin(cnP,cmP),handles.pmSin(cnP,cmP)]=ginputc(1, 'Color', 'w');
guidata(hObject,handles);
Please I will grateful with someone who could help me.
In my example hanldes has two elements (pnSin and pmSin).
Walter Roberson
2016년 10월 23일
Jose abel De la Fuente: you are writing the x and y outputs of ginputc to the same output location. The location is going to end up as just the y value.
채택된 답변
추가 답변 (1개)
Jing
2013년 3월 28일
0 개 추천
That's because you didn't update A after modification! Before disp, you should get A back from the handles by "A=handles.A;".
댓글 수: 3
Luca Amerio
2013년 3월 28일
Jan
2013년 3월 28일
Please do not post wrong code and mention this in a comment to an answer. Use the chance to edit the original question, because this would be less confusing for the readers. And when you want the assistence of voluntary helpers, any kind of confusion is a bad idea.
Luca Amerio
2013년 3월 28일
편집: Luca Amerio
2013년 3월 28일
카테고리
도움말 센터 및 File Exchange에서 Function Handles에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!