フィルターのクリア

Writing cells to text file without double quotes

54 ビュー (過去 30 日間)
M Teaxdriv
M Teaxdriv 2022 年 5 月 26 日
コメント済み: M Teaxdriv 2022 年 5 月 26 日
Hello guys,
I am trying to write cell vector to text file using fprintf - this does not work because it requires some formatting but I want to write it just "like it is" in the cells. Next I am trying writecell command - this works but it adds double quote at the beginning of each line in the text file what is super annoying.
The cells look like shown below:
After command writecell final text file looks like:
"/batch
"
"/config,noeldb,1 ! force off writing results to database
"
"*get,_wallstrt,active,,time,wall
but, of course, it should look like this in the written text file:
/batch
/config,noeldb,1 ! force off writing results to database
*get,_wallstrt,active,,time,wall
UPDATE: After using QuoteStrings set to false there are no quotation marks, but still there empty lines between each string. Do you have idea how to remove them?
Therefore I would like to ask you for help.
Best regards
Michal
  2 件のコメント
Stephen23
Stephen23 2022 年 5 月 26 日
編集済み: Stephen23 2022 年 5 月 26 日
" but it adds double quote at the beginning of each line in the text file..."
No it doesn't, it actually adds double quotes around your text. There is a difference.
"but still there empty lines between each string."
Because each of your character vectors ends with some kind of newline character.
"Do you have idea how to remove them?"
Remove the newline characters from the cell array, e.g. STRTRIM or DEBLANK or REGEXPREP.
M Teaxdriv
M Teaxdriv 2022 年 5 月 26 日
Hello Stephen23,
thank you for explanation!
Michal

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

採用された回答

Walter Roberson
Walter Roberson 2022 年 5 月 26 日
fprintf(fid, "%s\n", YourCell{:})

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by