diag灵活应用构造想要的矩阵
2017-01-16 by:CAE仿真在线 来源:互联网
>> c
c =
4.6796
2.6499
1.8997
1.2721
1.1027
>> diag(c)
ans =
4.6796
0
0
0
0
0
2.6499
0
0
0
0
0
1.8997
0
0
0
0
0
1.2721
0
0
0
0
0 1.1027
>> diag(c,0)
ans =
4.6796
0
0
0
0
0
2.6499
0
0
0
0
0
1.8997
0
0
0
0
0
1.2721
0
0
0
0
0 1.1027
>> diag(c,1)%红色字体为矩阵对角线元素,仔细观察非零数值与对角线的位置关系
ans =
0 4.6796
0
0
0
0
0 0 2.6499
0
0
0
0
0 0 1.8997
0
0
0
0
0 0 1.2721
0
0
0
0
0 0 1.1027
0
0
0
0
0 0
>> diag(c,-2)
ans =
0 0
0
0
0
0
0
0 0 0
0
0
0
0
4.6796
0 0 0
0
0
0
0
2.6499
0 0 0
0
0
0
0
1.8997
0 0 0
0
0
0
0
1.2721
0 0 0
0
0
0
0
1.1027
0 0
>> s
s =
4.6796
0
0
0
0
0
2.6499
0
0
0
0
0
1.8997
0
0
0
0
0
1.2721
0
0
0
0
0 1.1027
>> diag(s)
ans =
4.6796
2.6499
1.8997
1.2721
1.1027
>> diag(s,0)
ans =
4.6796
2.6499
1.8997
1.2721
1.1027
>> diag(s,1)
ans =
0
0
0
0
>> diag(s,-2)
ans =
0
0
0
>> A
A =
0.5377 -1.3077 -1.3499
1.8339
-0.4336 3.0349
-2.2588 0.3426
0.7254
0.8622 3.5784 -0.0631
0.3188
2.7694 0.7147
>> diag(A,-2)
ans =
-2.2588
3.5784
0.7147
>> diag(A,1)
ans =
-1.3077
3.0349
>> diag(A,0)
ans =
0.5377
-0.4336
0.7254
>> diag(A)
ans =
0.5377
-0.4336
0.7254
相关标签搜索:diag灵活应用构造想要的矩阵 MatLab培训 MatLab培训课程 MatLab在线视频教程 MatLab技术学习教程 MatLab软件教程 MatLab资料下载 MatLab代做 MatLab基础知识 Fluent、CFX流体分析 HFSS电磁分析 Ansys培训 Abaqus培训