MATLAB: Update variable and save previous values of an edit box each time i hit a button

edit textgui

Hello ,
  • I need to figure out some problem in GUi environment i have 4 edit box , first is aimed to indicate which node use define coordinate , the second third en forth edit box are the coordinates of this "Node".
  • So i extract value of each edit text box and i extract some new matrix call "Nodes" and each rows are corresponding to a point.
  • I have add also counter with add + 1 each time to the first edit text.Until there only problem is that each time new line is create all previous are setting back to zero.
  • So if there is someone could help me to figure out this problem that's could be great .
  • I join screen print of how look the menu , the code of the callback function of my button exit and the problem about the update of my variable Nodes.
  • Thank you in advance
  • PS : if you think i have chose wrong question i will be glad if you have some suggestion.

Best Answer

antoine - rather than saving your updated Nodes variable to the base workspace, why don't you just save it to the handles structure much like you do with the counter?
function Next_Callback(hObject, eventdata, handles)
handles.counter = handles.counter + 1;
if ~isfield(handles,'Nodes')
handles.Nodes = [];
end
X = str2double...; % I'm omitting code here, just use yours
Y = str2double...;
Z = str2double...;
handles.Nodes = [handles.Nodes ; [X Y Z] ];
guidata(hObject,handles);
With the above, you don't even need the counter (unless you are using it because you have already specified the size of Nodes?).