How to display matrix with n digits in each cells?

3 views (last 30 days)
Hi, I would like to know how to display a matrix with 3 digits in each cells. Not 4, not 2, 3 digits. Even if the value is zero, I want 0.00. If the value is 0.02, I need to have 2.00e-2.
I tried matrice_Q=round(Q,3,'significant'), and it doesn't work.
if true
Sr=matriceS(propmeca.verrepox,1);% This is a function who calls a matrix.
Sr =
1.0e-03 *
0.020000000000000 -0.005080000000000 0
-0.005080000000000 0.065789473684211 0
0 0 0.212765957446809
format shorteng
matrice_S=round(Sr,3,'significant')% 3 chiffres significatifs
And I get:
matrice_S =
20.0000e-006 -5.0800e-006 0.0000e+000
-5.0800e-006 65.8000e-006 0.0000e+000
0.0000e+000 0.0000e+000 213.0000e-006
end
How do I get rid of the zeros after the first 3 digits? I don't need precision, I need to display only 3 digits. Matlab won't use these results for further calculations.
if true
I need:
matrice_S =
20.0e-006 -5.08e-006 0.00e+000
-5.08e-006 65.8e-006 0.00e+000
0.00e+000 0.00e+000 213e-006
end
I want my matrix to look like this, straight, well placed, all lined up, and with the right number of digits. Could some body help me please?
Thanks! :)
Julien

Accepted Answer

Walter Roberson
Walter Roberson on 26 Oct 2018
disp(num2str(Sr, '%.2e '))

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!