diag靈活應(yīng)用構(gòu)造想要的矩陣
2017-01-16 by:CAE仿真在線 來源:互聯(lián)網(wǎng)
>> 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)%紅色字體為矩陣對(duì)角線元素,仔細(xì)觀察非零數(shù)值與對(duì)角線的位置關(guān)系
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
相關(guān)標(biāo)簽搜索:diag靈活應(yīng)用構(gòu)造想要的矩陣 MatLab培訓(xùn) MatLab培訓(xùn)課程 MatLab在線視頻教程 MatLab技術(shù)學(xué)習(xí)教程 MatLab軟件教程 MatLab資料下載 MatLab代做 MatLab基礎(chǔ)知識(shí) Fluent、CFX流體分析 HFSS電磁分析 Ansys培訓(xùn) Abaqus培訓(xùn)