Why are the matrix numbers changing?
Mostrar comentarios más antiguos
I'm trying to write a matrix but the numbers are changing. What could be the reason?

1 comentario
Stephen23
el 28 de Oct. de 2023
"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.
Respuestas (1)
A = [1.08 -1 0; 2184.02 -2185.02 1;0 -1 1.81]
%Change the output display format to shortG
format shortG
%see the change
A
%change the format back to default and check the output
format default
A
Categorías
Más información sobre Numeric Types en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!