- MATLAB is not saved as scientific counting method http://blog.sciencenet.cn/blog-472136-402727.html
Often in the expression of MATLAB value, it always put some less than 1 of the number greater than 1000 using scientific notation. This sometimes makes people uncomfortable, and it's bad to write data to a text file every time.
So every time I check to find out, this solution is the solution.
1), before setting format G;
2), use fprintf format to%g.
- matlab area--------------matlab How to preserve the decimal number of specific digits http://blog.csdn.net/yf210yf/article/details/7235907
Second, after the decimal point a rounding, that is, to retain a few decimals, also often used.
1. Numerical type roundn-arbitrary bit position rounding
>>a=123.4567890;
>>A=ROUNDN (a,-4)
A = 123.4568
where the ROUNDN function functions as follows:
y = Roundn (x) rounds the input data x to the nearest hundredth. % does not specify N, accurate to percentile
y = Roundn (x,n) rounds the input data x at the specified power% the specified number of digits after the decimal point n
Format G;A=ROUNDN (a,-4); B=roundn (b,-4); fid = fopen (' a.txt ', ' wt '); Fid2=fopen (' B.txt ', ' wt '); for i=1:m for J=1:n fprintf (FID, '%g ', A (i,j)); fprintf (FID, '%c ', ', '); fprintf (Fid2, '%g ', B (i,j)); fprintf (Fid2, '%c ', ', '); End fprintf (FID, '%c\n ', '); fprintf (Fid2, '%c\n ', '); End
MATLAB Specifies that the decimal point retains a 4-bit and non-scientific notation format for storing txt