convert numbers that contain the scientific notation e to the long format then round it to the fourth decimal?

13 次查看(过去 30 天)
Hello,
suppose that we have a matrix A (2*3) that contains the values:
A= [ 0.0037 0.0089 0.0057
0.0041 0.-3.000000000000000e-04 0.0034]
I need to make the elment A(2,2) to this form (-0.0003) , where A becomes:
A= [ 0.0037 0.0089 0.0057
0.0041 -0.0003 0.0034]
So, how can I do this?
Regards,

回答(1 个)

Guillaume
Guillaume 2019-7-21
编辑:Guillaume 2019-7-21
I assume that what you mean is that you'd like matlab to display numbers as -0.0003 instead of 3e-4. If so,
format shortg
will change the display to avoid scientific notation as much as possible.
If instead you're saying you want to store -0.0003 instead of 3e-4,. that makes no sense, they're the same numbers (and are stored internally in a completely different format). Furthermore, due to the way numbers are stored on a computer, it's actually impossible to store -0.0003 exactly (in ieee754 representation such as double or single). The actual number that is stored in memory is actually -0.0002999999999999999737189393389513725196593441069126129150390625, the nearest representable number to -0.0003. Any program will round that to -0.0003 for display.

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by