data appending in text file

2 ビュー (過去 30 日間)
Mohammad
Mohammad 2013 年 8 月 14 日
Hi,
I created a text file using MATLAB. For example, 10 by 3 matrix and I saved it as a text using fopen and fprint in particular format. Now I want to append lines (data)to this text, say at row 1, row 5, and row 10, i.e at a fixed interval. How can I do this. Remember, I need to add lots of these lines.
I greatly appreciate any help.
Thanks Rafiq

採用された回答

Cedric
Cedric 2013 年 8 月 14 日
編集済み: Cedric 2013 年 8 月 14 日
Instead of opening the file with write permission using 'w', open it in with append permission using 'a'.
  7 件のコメント
Mohammad
Mohammad 2013 年 8 月 15 日
Cedric,
So kind of you. Thanks a lot. This solved my problem and saved me a lot of time. Thanks again.
Rafiq
Cedric
Cedric 2013 年 8 月 15 日
You're welcome!

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 8 月 14 日
The only way to insert lines into a text file is to read in the file and write out the modified file. There is no way to seek directly to a particular line, and there is no way to insert in the middle of a text file.
Depending on what you want to insert into the file, you may wish to use system utilities such as "sed" or "awk" or "perl"

カテゴリ

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