Combining Matrices
3 ビュー (過去 30 日間)
古いコメントを表示
Hi, I have an upper traingular matrix andf a lower triangular matrix. Both have the exact same size. I want to combine these matrices along the diagonal to get a single composite matrix. How can I do that. Thanks.
採用された回答
Andrei Bobrov
2012 年 1 月 6 日
e.g.:
>> Ut = triu(randi(45,6))
Ut =
32 7 5 4 9 25
0 38 44 18 12 7
0 0 1 12 7 39
0 0 0 37 7 28
0 0 0 0 40 16
0 0 0 0 0 24
>> Lt = tril(randi(45,6))
Lt =
19 0 0 0 0 0
4 3 0 0 0 0
11 41 17 0 0 0
6 43 6 6 0 0
9 23 36 43 37 0
11 23 18 44 1 21
>> out1 = Ut + tril(Lt,-1)
out1 =
32 7 5 4 9 25
4 38 44 18 12 7
11 41 1 12 7 39
6 43 6 37 7 28
9 23 36 43 40 16
11 23 18 44 1 24
>> % OR
>> out2 = triu(Ut,1) + Lt
out2 =
19 7 5 4 9 25
4 3 44 18 12 7
11 41 17 12 7 39
6 43 6 6 7 28
9 23 36 43 37 16
11 23 18 44 1 21
>>
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Operating on Diagonal Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!