开发者

How can I control the display of a double matrix in MATLAB?

开发者 https://www.devze.com 2023-03-04 20:42 出处:网络
How can I change the format to NOT display a matrix like this: 1.0e+003 * 3.1251000000000 03.125100000000

How can I change the format to NOT display a matrix like this:

 1.0e+003 *

3.1251         0         0         0         0         0         0         0         0         0
     0    3.1251         0         0         0         0         0         0         0         0
     0         0    3.1251         0         0         0         0         0         0         0
     0         0         0    3.1251         0         0         0         0         0         0
     0         0         0         0    3.1251         0         0         0         0         0
     0         0         0         0         0    3.1251         0         0         0         0
     0         0         0         0         0         0    3.1251         0         0         0
     0         0         0         0         0         0         0    3.1251         0         0
     0         0         0         0         0         0         0         0    3.1251         0
     0         0         0         0         0         0         0         0         0    3.1251

but instead to include the 开发者_开发技巧1.0e+003 into every double so that the matrix looks like 3125 along the diagonal?


You can get the output you want if you change the format to shortG (based on Example 5 of the documentation):

>> format shortG
>> 3125.1234.*eye(5)   %# Display a sample matrix similar to yours

ans =

       3125.1            0            0            0            0
            0       3125.1            0            0            0
            0            0       3125.1            0            0
            0            0            0       3125.1            0
            0            0            0            0       3125.1
0

精彩评论

暂无评论...
验证码 换一张
取 消