フィルターのクリア

write from cell aray to txt file

2 ビュー (過去 30 日間)
Andrea Somma
Andrea Somma 2022 年 5 月 8 日
編集済み: dpb 2022 年 5 月 8 日
I have a cell array like this:
I want to write it line by line into a txt file (so I can chose which line to write whith an if), I also have to put a whitespace between every cell like this:
the number of whitespaces beetween each cell doesn' t make any difference, I can' t figure out how to write it (the cell array is pretty large so an optimized solution would be handy)
thank you for the support in advance
  2 件のコメント
Rik
Rik 2022 年 5 月 8 日
You have a cell array of char arrays, so the obvious way to write that is with a loop. Are you able to write text to a file?
Andrea Somma
Andrea Somma 2022 年 5 月 8 日
編集済み: Andrea Somma 2022 年 5 月 8 日
I guess with a fprintf loop? But I dont know how to manage spaces in an optimized way

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

採用された回答

dpb
dpb 2022 年 5 月 8 日
fprintf example <<Tabular text file> illustrates a fixed-width text file...if that's the intent use the width parameter on the '%s' and other format strings as you desire.
If the point is to just write a delimited file, then cellwrite is the simplest route -- if you don't want all rows, then create a logical addressing vector of those that are to be written and use it to only select the rows wanted when pass the array.
  4 件のコメント
Andrea Somma
Andrea Somma 2022 年 5 月 8 日
Thank you, I didnt know that matlab feature to negate the index of the array, very helpful!
dpb
dpb 2022 年 5 月 8 日
編集済み: dpb 2022 年 5 月 8 日
See <not, ~> Read up on "logical indexing"

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by