MATLAB: How to add value of same variable in mat-file within function in GUI

.mat fileguisave

Hello!
I have GUI-function 'editProc_Callback'. After entering and reading numbers in field 'edit' MATLAB performs calculations resulting in struct variable REGISTR:
function editProc_Callback(hObject, eventdata, handles)
Trab2=str2num(get(hObject, 'String'));
set(hObject,'string',num2str(Trab2));
...
REGISTR(n).data=[tttt;regis];
REGISTR(n).nazv=nazvan;
REGISTR(n).time=time(tttt)';
save registr REGISTR
This works fine. Size of REGISTR is 1×1. Problems starts when I repeatedly enter numbers in field 'edit' and perform function 'editProc_Callback'. After that variable REGISTR does not contain data of first performing function 'editProc_Callback' and has size 1×1 so far.
Briefly, how can I get struct variable REGISTR with size 1xN, where N – number of performing function 'editProc_Callback'?
Thank you!

Best Answer

function editProc_Callback(hObject, eventdata, handles)
Trab2=str2num(get(hObject, 'String'));
set(hObject,'string',num2str(Trab2));
...
REGISTR = handles.REGISTR; % Define this field in the OpeningFcn
n = numel(REGISTR) + 1;
REGISTR(n).data = [tttt;regis];
REGISTR(n).nazv = nazvan;
REGISTR(n).time = time(tttt)';
handles.REGISTR = REGISTR;
guidata(hObject, handles); % Store handles in the GUI
% save registr REGISTR % Is this really wanted?