Matlab: how to display the “real” values of an array?

亡梦爱人 提交于 2019-12-20 07:43:21

问题


I have a vector that is caluculated in a script.

After calculation, I display the values to the command window. It is displayed as follows:

finalResults =
1.0e+05 *
0.0001
     0
0.0005
0.0002
0.0001
0.0027
0.0033
0.0001
-0.0000
-0.0000
1.3750
0.0066

How do I make it display with the real values (i.e. with the 1.0e+05 multiplied in)?


回答1:


format longG should do the trick. This uses either long or longE, whichever is shorter for each element. Same can be done with format shortG if you want shorter sequences.

The reason MATLAB displays numbers like in your question, is because this is the format short way of doing things. Look at format in the documentation to see all the options.

Example:

format shortG
A = [1;1e10;-1];
A =

            1
        1e+10
           -1
format longG
A =

                         1
               10000000000
                        -1


来源:https://stackoverflow.com/questions/32524059/matlab-how-to-display-the-real-values-of-an-array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!