How can i save the text area characters to a text file in app designer?
이전 댓글 표시
I need to save notes in the text area to a specific location. How to save the data using app designer?
채택된 답변
추가 답변 (2개)
kuldeep vaishnav
2020년 5월 24일
0 개 추천
value = app.TextArea.Value; % Value entered in textArea
f=fopen('a.txt','w');
formatSpec= "%s";
for i =1:length(value)
fprintf(f,formatSpec,value{i});
end
David Szwer
2021년 2월 19일
Try using the writecell() function. As far as I can tell, although a TextArea's Value can be set in numerous different formats, when used as an output it always emerges as a cell array of character arrays (one line in each cell). writecell() turns this straight back into a multiline text file. Adapting Siriniharika Katukam's answer:
value = app.TextArea.Value; % Value entered in textArea
writecell(value, 'a.txt', 'QuoteStrings',false);
Matlab's documentation suggests that QuoteStrings is false by default; I found that it was true by default so you need to turn it off.
댓글 수: 2
David Duque
2021년 7월 22일
how can I choose a path to save the txt file?
David Szwer
2021년 7월 23일
'a.txt' is the filename. Replace that with the filename you want, including the full path.
카테고리
도움말 센터 및 File Exchange에서 Develop Apps Programmatically에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!