フィルターのクリア

Convert string to txt

29 ビュー (過去 30 日間)
Jose Grimaldo
Jose Grimaldo 2020 年 4 月 2 日
編集済み: Ameer Hamza 2020 年 4 月 5 日
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 件のコメント
Jose Grimaldo
Jose Grimaldo 2020 年 4 月 2 日
nwm i figure it out. Once i fclose is it consider save as txt file or do i have to inset at the end after fclose save('A.txt') ?
Ameer Hamza
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
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!

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by