Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Could nt get the result
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Walter Roberson
am 17 Mai 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 Kommentare
Walter Roberson
am 17 Mai 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
am 17 Mai 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?
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!