Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Octave terminal to output numbers without scientific notation?

Tags:

octave

I am trying to print a long table of numbers in octave terminal.

disp(vec);

What I get

7.0931e-01
6.2041e-05
9.7740e-01
9.9989e-01
8.8428e-01
9.0524e-01
...

Such numerical notation is a pain to read. How can I set octave terminal to output numbers normally as 0.7, 0.014, 0.95?

like image 360
minerals Avatar asked Nov 28 '16 15:11

minerals


2 Answers

You can use format short g to display each number is a more logical format

format short g
disp(vec)

%     0.70931
%  6.2041e-05
%      0.9774
%     0.99989
%     0.88428
%     0.90524
like image 194
Suever Avatar answered Oct 04 '22 14:10

Suever


Using 'fprintf' could help in such cases

a=0.0001234;
fprintf('%.3f\n',a)

But here the limitation is that number of decimal points would be fixed so in some numbers it will display zeros at the end while for some numbers it might cut off the number.

like image 24
Mittal Patel Avatar answered Oct 04 '22 15:10

Mittal Patel