how do i transfer matrix variable of an image from gui callback function to a another call back function (pushbutton1_Callback ----> pushbutton2_Callback)

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

 Accepted Answer

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!

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!