Why are the matrix numbers changing?

I'm trying to write a matrix but the numbers are changing. What could be the reason?

댓글 수: 1

Stephen23
Stephen23 2023년 10월 28일
"I'm trying to write a matrix but the numbers are changing. What could be the reason?"
The values are not changing. You are mixing up two different things:
  • how numeric values are stored in memory
  • how numeric values are displayed as text (e.g. in the command window).
There is no one canononical way to display numbers (or numeric values), what you see are simply those values displayed using the default display FORMAT (which happens to have four decimal places and a common multiplier in the top left corner). Use the FORMAT function if you want some other display format.

댓글을 달려면 로그인하십시오.

답변 (1개)

Dyuman Joshi
Dyuman Joshi 2023년 10월 28일

1 개 추천

The numbers are not changing, the default display format is such.
A = [1.08 -1 0; 2184.02 -2185.02 1;0 -1 1.81]
A = 3×3
1.0e+03 * 0.0011 -0.0010 0 2.1840 -2.1850 0.0010 0 -0.0010 0.0018
%Change the output display format to shortG
format shortG
%see the change
A
A = 3×3
1.0e+00 * 1.08 -1 0 2184 -2185 1 0 -1 1.81
%change the format back to default and check the output
format default
A
A = 3×3
1.0e+03 * 0.0011 -0.0010 0 2.1840 -2.1850 0.0010 0 -0.0010 0.0018

카테고리

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

질문:

2023년 10월 28일

댓글:

2023년 10월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by