How would I create a GUI with a push button that when clicked, guy data will be save in .txt file?
조회 수: 2 (최근 30일)
이전 댓글 표시
답변 (1개)
Jalaj Gambhir
2019년 10월 17일
Hi,
You can do so by adding a SaveFileButtonPushed() callback. In this function you can access the values of the fields and dump it to text file using fprintf, as shown below:
function SaveFileButtonPushed(app, event)
name = app.NameEditField.Value;
age = app.AgeEditField.Value;
sex = app.SexEditField.Value;
height = app.HeightEditField.Value;
fileID = fopen('data.txt','w');
fprintf(fileID,"%s\t%s\t%s\t%s\t",name,age,sex,height);
end
end
댓글 수: 1
Salina
2022년 7월 11일
In this very example you gave, how to keep on adding the data to the text file on every click?
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!