How to modify all the datas in a txt files?

1 回表示 (過去 30 日間)
Jiajie Zhang
Jiajie Zhang 2019 年 1 月 20 日
コメント済み: Star Strider 2019 年 1 月 20 日
I have a txt file like this:
9,15,5,10,14,5,11,15,5,7,19,0,4,22,0
7,8,7,10,8,4,11,7,0,9,12,7,11,11,0
9,15,5,10,14,5,11,15,5,7,19,0,4,22,0
9,4,4,10,5,0,11,3,4,11,7,0,13,2,0
How do I modify all the datas and store as the same format, such as add 1 to all the data, and get:
10,16,6,11,15,6,12,16,6,8,20,1,5,23,1
.....
The sample of my orginal data is given as the attachment.
Thanks in advance.
  2 件のコメント
Stephen23
Stephen23 2019 年 1 月 20 日
@Jiajie Zhang: please upload a sample file by clicking the paperclip button.
Jiajie Zhang
Jiajie Zhang 2019 年 1 月 20 日
Thanks for the notification, just updated.

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

採用された回答

Star Strider
Star Strider 2019 年 1 月 20 日
Try this:
D = load('output.txt')
D = D+1;
P = 'Your_Path';
save(fullfile(P,'output1.txt'), 'D', '-ascii');
D1 = load('output1.txt') % Check
The second load call is not absolutely necessary. It simply shows that the changes were made, and that the file saved correctly.
  2 件のコメント
Jiajie Zhang
Jiajie Zhang 2019 年 1 月 20 日
Thank you so much.
That's very brilient!
Star Strider
Star Strider 2019 年 1 月 20 日
As always, my pleasure.
Thank you!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by