MATLAB: GUI Error: ‘Struct contents reference from a non-struct array object’ when saving the input from user using ‘edit text’

edit textgui

I'd try to save the InputQ1_old value in Result_Study1 but got the error shows:
Struct contents reference from a non-struct array object.
Error in task2>total_new_CreateFcn (line 563) InputQ1_old=handles.metricdata.T1_old;
Do you guys have any idea what's wrong with this code? I'd use the edit text toolbox from GUI so that the user can enter the value of T1_old.Here is my code:
function T1_old_Callback(hObject, eventdata, handles)
T1_old=str2double(get(hObject,'String'));
if isnan(T1_old)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
% Save the new T1_old value
handles.metricdata.T1_old = T1_old;
guidata(hObject,handles)
InputQ1_old=handles.metricdata.T1_old;
save('ResultStudy1', 'InputQ1_old')
Thanks

Best Answer

Your total_new_CreateFcn is likely being run before T1_old_Callback has been run.