MATLAB: I have 10 text boxes that are used to store data in an column matrix. I cannot save them in a column matrix.

matlab gui

The text boxes will not save them. The first input is recorded, but the moment I input the second value or input, the first element in the matrix becomes zero. What should I do?

Best Answer

Hard to say without code but II suspect that your callbacks look something like
boutput = zeroes(8, 1);
tt = str2double( get(hObject,'string') );
boutput(4) = tt; %for 4th box
save boutput.mat boutput
The problem with this is that it always zeroes the array instead of fetching the current array and storing that.
if isfield(handles, 'boutput')
boutput = handles.boutput;
else
boutput = zeroes(8,1);
end
....
handles.boutput = boutput;
guidata(hObject, handles );