Convert string to txt
조회 수: 29 (최근 30일)
이전 댓글 표시
I have a 4x1 string array, how can i write it and save it as a txt file? Not sure if i did it correctly.
A=(4x1) string array
fid = fopen('A.txt','wt');
fprintf(fid, '%s\n',A);
fclose(fid);
댓글 수: 5
Ameer Hamza
2020년 4월 2일
편집: Ameer Hamza
2020년 4월 5일
You should not run save('A.txt'). It is useless for your problem.
답변 (1개)
Maadhav Akula
2020년 4월 5일
Hi,
I think you are getting that extra line because of the '\n' escape character. You can try the following code :
fid = fopen('A.txt','w');
fprintf(fid, '%s\n',A(1:end-1));
fprintf(fid,'%s',A(end));
fclose(fid);
Hope this Helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!