Reputation: 2192
I made a GUI program to process and view images. I wrote some of the codes that are used more than once in helper functions those are called within the GUI function callbacks to make it more concise.
However, I've a trouble with saving changes to handles structure if I write my program in this way. The calculation in the helper function was done correctly when I examined it in debugging mode. But the changes to the handles structure was not updated.
I'm wondering of how I can fix this?
Code :
function ProcessData_Callback(hObject, eventdata, handles) % GUI callback
val = get(handles.menu, 'Value');
str = get(handles.menu, 'String');
switch str{val}
case 'Mode1'
FRETCalculator1(handles);
case 'Mode2'
FRETCalculator2(handles);
end
function FRETCalculator1(handles) % Helper function
for indT = 1:size(handles.Data,1)
for indZ = 1:size(handles.Data,3)
handles.Data{indT,3,indZ} = handles.Data{indT,1,indZ}./(handles.Data{indT,2,indZ}+1);
end
end
guidata(handles.mainGUI, handles);
Upvotes: 1
Views: 94
Reputation: 334
This line of yours should actually save the changes :
guidata(handles.mainGUI, handles);
Now if you want to use the handles that were modified after calling your function, you have to actualize them :
FRETCalculator1(handles);
handles=guidata(handles.mainGUI);
% ...code using modified handles
Actually, handles are modified in the figure but not in the code executing after the function call.
I hope that was clear. :)
Upvotes: 1