How to round the decimal?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
laith Farhan
am 27 Jun. 2018
Kommentiert: Star Strider
am 27 Jun. 2018
Dear All;
I have a number array x = [0.00135678 0.00076243;0.0000045789 0.01234567];
Then i just want to round x to become as: results:[0.0013 0.00076; 0.0000045 0.012];
What to do?
Thanks in advance.....
0 Kommentare
Akzeptierte Antwort
Star Strider
am 27 Jun. 2018
Try this:
x = [0.00135678 0.00076243;0.0000045789 0.01234567];
L10 = log10(x); % Base 10 Logarithm
mant = fix(10.^rem(L10,1)*100); % Calculate Mantissa & Remove Extra Digits
expt = floor(L10)-1; % Determine Exponent
Result = mant .* 10.^expt
Result =
0.001300000000000 0.000760000000000
0.000004500000000 0.012000000000000
2 Kommentare
Weitere Antworten (1)
Steven Beumer
am 27 Jun. 2018
Bearbeitet: Stephen23
am 27 Jun. 2018
You might want to check out this function for that:
0 Kommentare
Siehe auch
Kategorien
Mehr zu Elementary Math finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!