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

2 次查看(过去 30 天)
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?

回答(1 个)

Image Analyst
Image Analyst 2016-9-25
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;

类别

Help CenterFile Exchange 中查找有关 Large Files and Big Data 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by