How to save matrix to .dat file in standard notation

조회 수: 40 (최근 30일)
Dipie11
Dipie11 2019년 4월 22일
댓글: Dipie11 2019년 4월 22일
Hi!
I would like to save a binary matrix 'A' to the file 'output.dat' without scientific notation formatting. For instance the matrix A has the (1,1) element, A(1,1) = 0. But it is saved as 0.0000000..e+00, when I'd simply like to to be saved as just 0.
I'm currently using the following basic save function,
A = [0 1 1 0; 0 0 0 1; 1 0 1 0; 0 0 0 0] % Example binary matrix A
save(['output=' num2str(i+1) '.dat'],'A','-ascii');
any help would be greatly appreciated.
Thank you!

채택된 답변

Walter Roberson
Walter Roberson 2019년 4월 22일
You cannot do that using save -ascii: save -ascii uses a fixed format.
Probably the easest way is
filename = sprintf('output=%d.dat', i+1);
dlmwrite(filename, A, ' ' )

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by