[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
"format short f"
From: |
Dirk Laurie |
Subject: |
"format short f" |
Date: |
Fri, 4 Aug 2000 13:22:16 +0200 |
I know that Matlab is like that too, but I find the insistence on
significant figures at all times annoying.
Example:
A=hilb(8)
A =
1.0000 0.5000 0.3333 0.2500 0.2000 0.1667 0.1429 0.1250
0.5000 0.3333 0.2500 0.2000 0.1667 0.1429 0.1250 0.1111
0.3333 0.2500 0.2000 0.1667 0.1429 0.1250 0.1111 0.1000
0.2500 0.2000 0.1667 0.1429 0.1250 0.1111 0.1000 0.0909
0.2000 0.1667 0.1429 0.1250 0.1111 0.1000 0.0909 0.0833
0.1667 0.1429 0.1250 0.1111 0.1000 0.0909 0.0833 0.0769
0.1429 0.1250 0.1111 0.1000 0.0909 0.0833 0.0769 0.0714
0.1250 0.1111 0.1000 0.0909 0.0833 0.0769 0.0714 0.0667
A*inv(A)
ans =
Columns 1 through 6:
1.00e+00 3.66e-08 -4.47e-08 -1.79e-07 5.51e-07 -7.00e-07
6.23e-09 1.00e+00 -3.91e-08 -1.57e-07 4.71e-07 -5.75e-07
5.37e-09 2.64e-08 1.00e-00 -1.40e-07 4.09e-07 -5.29e-07
4.72e-09 2.31e-08 -2.66e-08 1.00e-00 3.62e-07 -4.72e-07
4.20e-09 2.07e-08 -2.61e-08 -1.03e-07 1.00e+00 -4.01e-07
3.80e-09 1.86e-08 -2.08e-08 -9.92e-08 2.82e-07 1.00e-00
3.46e-09 1.70e-08 -2.18e-08 -7.54e-08 2.45e-07 -2.92e-07
3.18e-09 1.55e-08 -1.87e-08 -8.46e-08 2.58e-07 -3.07e-07
Columns 7 and 8:
5.51e-07 -3.02e-07
4.84e-07 -2.52e-07
4.29e-07 -2.14e-07
4.10e-07 -1.98e-07
3.03e-07 -1.72e-07
3.17e-07 -1.65e-07
1.00e+00 -1.38e-07
2.59e-07 1.00e-00
I'd like something that allows me to print this last item as
ans =
1.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
0.0000 1.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
-0.0000 -0.0000 1.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000
-0.0000 -0.0000 -0.0000 1.0000 -0.0000 -0.0000 -0.0000 -0.0000
0.0000 0.0000 0.0000 0.0000 1.0000 0.0000 0.0000 0.0000
-0.0000 -0.0000 -0.0000 -0.0000 -0.0000 1.0000 -0.0000 -0.0000
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 1.0000 0.0000
-0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 1.0000
The most flexible candidate would be:
format(FORMATSTRING)
where FORMATSTRING is a sprintf-like string. E.g. I get the above by
specifying format('%9.4f') (I didn't, but I would like to.)
Dirk
-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.che.wisc.edu/octave/octave.html
How to fund new projects: http://www.che.wisc.edu/octave/funding.html
Subscription information: http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------
- "format short f",
Dirk Laurie <=