MATLAB Answers

Using save() and -ascii format to limit output numbers to 2 decimals

173 ビュー (過去 30 日間)
adi kul
adi kul 2017 年 6 月 7 日
回答済み: Do Hieu Trinh 2021 年 4 月 15 日
Hello All, I need help with save() command. here is the extract of my code:
Where x is a column of 120 values upto 2 decimal points.
Now what I am getting with above code is 4.7300000e+01 which I want to limit to 47.30 only. I know they are one of same but I have another script which reads only 47.30 kind of format. So even though both are same I have to restrict it to 2 decimals only.
So is there any way to do that?


Stephen 2017 年 6 月 7 日
編集済み: Stephen 2017 年 6 月 7 日
Method one: fprintf:
fnm = fullfile(PathName,filename);
fid = fopen(fnm,'wt');
Method two: dlmwrite:
  6 件のコメント
Jabbar moosavi
Jabbar moosavi 2020 年 2 月 7 日
I've same question ,the reference data has 3 columns " x,y and pixel values" but this code save the data under "x".I want all the values in the same columns .
so how can I do that ?


その他の回答 (1 件)

Do Hieu Trinh
Do Hieu Trinh 2021 年 4 月 15 日
Dear Stephen,
Do you know a trick which works for saving data into .m file using
Best regards,
Do Hieu.


Community Treasure Hunt

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

Start Hunting!

Translated by