필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Thanos Lampridis
Thanos Lampridis 2016년 9월 25일
답변: Image Analyst 2016년 9월 25일
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