What is the best way to save data into a txt file

134 views (last 30 days)
I have these data in a matrix and I want to save them into a txt file
but I got diffrenet values than what in my matrix it was something like this (in that format)
4.6998106645411053e+02
I used save fuction to try and save my data I want to save is there another way to save data into txt file?
save('new doc.txt','M','-ascii','-double','-tabs') % M is the matrix
type('new doc.txt')
6540601141.61867 13577823444.2938 28101317825.1798
7569519373.48601 15264346993.3944 30754547025.5567
7387340146.18493 15158865708.5425 31019062144.9410
6251317371.90850 12958424682.6582 26803084252.4354
6734644847.83862 13687649437.8130 27810201085.8812
6849537690.44554 14134553528.2659 29089340966.3231
7385568328.07828 15044694671.3799 30591374573.0212
6381280737.62946 12989993198.7250 26448459532.9256
  3 Comments
will99
will99 on 22 Mar 2019
I was trying to save it in txt file is fprintf the best way for txt format?

Sign in to comment.

Accepted Answer

madhan ravi
madhan ravi on 22 Mar 2019
If your using 2019a you may try the newly introduced writematrix().
  1 Comment
will99
will99 on 22 Mar 2019
Thank you I have Matlab 2018b but I will update it and try the new function

Sign in to comment.

More Answers (0)

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!