When are newline and tab not recognized

2 ビュー (過去 30 日間)
Sushmitha Kudari
Sushmitha Kudari 2020 年 4 月 25 日
コメント済み: Sushmitha Kudari 2020 年 4 月 27 日
I have the following code. I am not sure why the newline is not creating a new line. I use dlm write to write out footer to a '.env' file. But I don't think that makes a difference.
footer = ['''A'' 0 \n'];
footer = [footer, num2str(depth_bottom) ' ' num2str(avg_ssp) ' ' num2str(0) ' ' num2str(1) '\t/\n'];
This is the output I am getting.
>> footer
footer =
''A' 0 \n5000 1600 0 1\t/\n'
The actual output should be:
'A' 0
5000.0 1600.00 0.0 1.0
  1 件のコメント
Image Analyst
Image Analyst 2020 年 4 月 26 日
So the output you are getting is
footer = ['''A'' 0 \n'];
footer = [footer, num2str(depth_bottom) ' ' num2str(avg_ssp) ' ' num2str(0) ' ' num2str(1) '\t/\n'];
but you were expecting to get
'A' 0
5000.0 1600.00 0.0 1.0
??? That's what you said. How are you calling dlmwrite()? I don't know why it would say "footer = ...." unless you somehow told it that "footer = ....." was in the header lines you told it to use.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2020 年 4 月 26 日
Outside of sprintf and sprintf and a small number of other places, \n just means \ followed by n.
I recommend that you use sprintf to build the string.
  1 件のコメント
Sushmitha Kudari
Sushmitha Kudari 2020 年 4 月 27 日
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Report Generator についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by