Write in a text file from GUI appending new results down from older

1 view (last 30 days)
I'm writing a GUI where i count seven values and put on a uitable. I want to push a button and, when i have new results, I want to append them down from the older several times. The idea is that when i push the button Save Results to Text File these values go to a text file named "My Results.txt" and when I have new values to append them down from these. Something like this
hammer -0.148 -0.2706 e.t.c pliers -0.248 -0.8979 e.t.c
My values go to the table with a separate button. The code is:
data = get(handles.uitable2, 'data');
data = {(get(handles.name,'String')),handles.imload1,handles.imload2,handles.imload3,handles.imload4,handles.imload5,handles.imload6,handles.imload7};
set(handles.uitable2, 'data', data);
Any help?

Answers (1)

Image Analyst
Image Analyst on 25 Sep 2016
You get data from the uitable, but then you just overwrite it with your new data. You need to assign the new data to another variable and then append
data = get(handles.uitable2, 'data');
newData = {(get(handles.name,'String')),handles.imload1,handles.imload2,handles.imload3,handles.imload4,handles.imload5,handles.imload6,handles.imload7};
set(handles.uitable2, 'data', data);
data = [data; newData];
set(handles.uitable2, 'data'); % or handles.uitable2.Data = data;

Categories

Find more on Large Files and Big Data in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!