I notice the values I get from octave are rounded to 5 decimal places. How can I increase that to 6 or 8 for example?
Increasing precision of Octave
14
$\begingroup$
math-software
octave
-
11Googling "octave precision digits" yielded [this](http://sci4um.com/about6809.html) as the 7th hit, and the one in which the brief "blurb" in Google page suggested a match. I know absolutely **nothing** about octave, so I can't vouch for the answer, but it does lead me to wonder... did *you* try googling? – 2012-03-14
2 Answers
14
As noted by William DeMeo in the comments, the command format
is what you're looking for. In fact, format
is common to both Matlab and Octave.
The command is
format options
where options are:short
for 3 significant figures,long
for 15 significant figures,long e
(orE
) andshort e
(orE
) for using scientific notation ...
More is in manual here link
12
The real answer was never posted to this and I ended up here while trying to find it. The output_precision
command is what you want. Setting format long
provides much more than the requested amount of precision. That may be okay, but if you want a specific precision, use output_precision
instead.
>> help output_precision 'output_precision' is a built-in function from the file libinterp/corefcn/pr-output.cc -- VAL = output_precision () -- OLD_VAL = output_precision (NEW_VAL) -- output_precision (NEW_VAL, "local") Query or set the internal variable that specifies the minimum number of significant figures to display for numeric output. When called from inside a function with the "local" option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function. See also: format, fixed_point_format, output_max_field_width. Additional help for built-in functions and operators is available in the online version of the manual. Use the command 'doc ' to search the manual index. Help and information about Octave is also available on the WWW at http://www.octave.org and via the help@octave.org mailing list. >> output_precision ans = 15 >> output_precision(7) >> a = [1 4.4 4.4^2 4.4^3 4.4^4 4.4^5;] a = 1.000000 4.400000 19.360000 85.184000 374.809600 1649.162240 >> output_precision(4) >> a = [1 4.4 4.4^2 4.4^3 4.4^4 4.4^5;] a = 1.0000 4.4000 19.3600 85.1840 374.8096 1649.1622