Matlab中矩阵内列的顺序差异

use*_*983 5 matlab matrix

我有一个矩阵的两列的以下输出:

final_matrix2 =

    0.0054    0.0000
    0.0051    0.0000
    0.0047    0.0000
    0.0042    0.0000
    0.0056    0.0000
    0.0034    0.0000
    0.0059    0.0000
Run Code Online (Sandbox Code Playgroud)

第二列由零组成,因为它是1e-9或1e-10或甚至更低的顺序.

我假设由于两列中元素之间的大小(顺序)不同而出现这些零.

有没有办法正确显示同一矩阵中两列中的元素?

lea*_*vst 3

首先我模拟你的问题。。

>> finalMatrix = randn(5,2)

finalMatrix =

   -1.3499   -0.2050
    3.0349   -0.1241
    0.7254    1.4897
   -0.0631    1.4090
    0.7147    1.4172

>> finalMatrix(:,2) = finalMatrix(:,2)*1e-20

finalMatrix =

   -1.3499   -0.0000
    3.0349   -0.0000
    0.7254    0.0000
   -0.0631    0.0000
    0.7147    0.0000
Run Code Online (Sandbox Code Playgroud)

然后使用该format命令显示缺失的精度(longG格式最适合您的特定问题)。。

    >> format longG
    >> finalMatrix

    finalMatrix =

             -1.34988694015652     -2.04966058299775e-21
              3.03492346633185     -1.24144348216312e-21
             0.725404224946106      1.48969760778546e-20
           -0.0630548731896562      1.40903448980048e-20
             0.714742903826096      1.41719241342961e-20

    >> 
Run Code Online (Sandbox Code Playgroud)