How to fix output of matrix values showing as 0 because they're being multiplied by the biggest power of 10?

1 view (last 30 days)
This is my code:
function [ SurfaceArea, N ] = SNparticles( A )
A = input('Enter particle diameter: ');
D=A*0.000001;
n = input('Specify mass of material sample in g : ');
m = n./1000;
SG = input('Enter specific gravity of material: ');
d = SG*1000;
SurfaceArea = (6*m./(D*d));
N = (6*m./(pi*(D.^3)*d));
end
It's showing up like
N =
1.0e+23 *
1.9099 0.0019 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
Values should be something like
1.90986E+23, 1.90986E+20, 1.90986E+17, 1.90986E+14, 1.22231E+13, 1.52789E+12, 3.73019E+11, 1.90986E+11
But since matlab is outputting all with the same power of 10 they get messed up.
What can I do?

Answers (1)

Walter Roberson
Walter Roberson on 10 Mar 2020
Give the command
format long g
You might want to consider changing your Preferences to change the default format.

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!