how do i transfer matrix variable of an image from gui callback function to a another call back function (pushbutton1_Callback ----> pushbutton2_Callback)
3 views (last 30 days)
Show older comments
Tishan Kumarasinghe
on 31 Aug 2016
Commented: Stephen23
on 31 Aug 2016
function pushbutton1_Callback(hObject, eventdata, handles)
handles.imgin = uigetfile();
guidata(hObject,handles)
i need to transfer loaded image matrix variable to below function
function pushbutton2_Callback(hObject, eventdata, handles)
imgin = guidata(hObject,handles.imgin);
but i fail to get the loaded image matrix from here
1 Comment
Accepted Answer
Geoff Hayes
on 31 Aug 2016
Tishan - you don't need to use guidata to access the field of handles that has been update with imgin. Rather than doing
function pushbutton2_Callback(hObject, eventdata, handles)
imgin = guidata(hObject,handles.imgin);
just do
function pushbutton2_Callback(hObject, eventdata, handles)
if isfield(handles,'imgin')
imgin = handles.imgin;
% rest of code goes here
end
Try the above and see what happens!
0 Comments
More Answers (1)
Image Analyst
on 31 Aug 2016
Geoff's solution is one of several suggested in the FAQ. See the FAQ if you want to see alternatives. http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!