Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Could nt get the result
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
f=figure;
c=uicontrol;
c.String='getrsf';
function getrsf_Callback(hObject, eventdata, handles)
% hObject handle to msg_box (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
demo;
end
0 comentarios
Respuestas (1)
Walter Roberson
el 17 de Mayo de 2020
c.Callback = @(s,e) getrsf_Callback(s, e, guidata(s))
That is to say, the String property of a uicontrol has no effect on callbacks: it is what the uicontrol displays.
When you create a gui using Guide then one of the things it does for you is to link in callbacks on your behalf. It does that by setting the Callback (or appropriate) property of the graphics objects saved in the fig file.
It also links the graphic object into handles on your behalf. It does that at the time it loads the gui by looking for Tag properties of graphic objects and creating fields in the handles structure for each valid Tag.
Note that these are two separate processes: callbacks saved as part of the object properties, and glue logic when the gui initializes that creates handles according to Tag.
When you create a graphics object yourself you need to set the callback property yourself. If you want you can also add the item into the handles structure.
3 comentarios
Walter Roberson
el 17 de Mayo de 2020
c.Callback = @(hObject, eventdata) getrsf_Callback(hObject, eventdata, guidata(s))
shuld i replace your given line with that function i my code
No, this code is what is needed if you want to invoke your
function getrsf_Callback(hObject, eventdata, handles)
as a callback. Only change it if you name your callback something different.
Note: you will also want to set the Position property of your uicontrol.
Image Analyst
el 17 de Mayo de 2020
Sandhiya, Did you just cut and paste small snippets of an application you'd created in GUIDE? If so, attach the .m and .fig file. Or is that your whole program?
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!