Changing decimals shown in matrix?

Hi!
I have matrix:
A = [(1:1:5); (-5:0.5:-3); (0:4); (10:-1:6); (2:2:10)]
%it gives me
A =
1.0000 2.0000 3.0000 4.0000 5.0000
-5.0000 -4.5000 -4.0000 -3.5000 -3.0000
0 1.0000 2.0000 3.0000 4.0000
10.0000 9.0000 8.0000 7.0000 6.0000
2.0000 4.0000 6.0000 8.0000 10.0000
% i want to see
A =
1.0 2.0 3.0 4.0 5.0
-5.0 -4.5 -4.0 -3.5 -3.0
0.0 1.0 2.0 3.0 4.0
10.0 9.0 8.0 7.0 6.0
2.0 4.0 6.0 8.0 10.0
My question is, is it possible to control the amount of decimals in the matrix? Can someone help me to understand this

답변 (1개)

Rik
Rik 2020년 5월 28일

0 개 추천

You can control this with the fomat function. The closest you can get is two decimals with
format bank
You should be aware that how Matlab stores data and how Matlab displays data isn't very strongly linked.
You can use fprintf to display your data any way you like.

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

질문:

2020년 5월 28일

답변:

Rik
2020년 5월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by