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);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/156600/image.bmp)
Any help?
댓글 수: 0
답변 (1개)
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;
댓글 수: 0
참고 항목
카테고리
Help Center 및 File 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!