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!