필터 지우기
필터 지우기

Combining Matrices

조회 수: 5 (최근 30일)
Syed Abbas
Syed Abbas 2012년 1월 6일
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.
  댓글 수: 1
Oleg Komarov
Oleg Komarov 2012년 1월 6일
Please supply an example.

댓글을 달려면 로그인하십시오.

채택된 답변

Andrei Bobrov
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
>>
  댓글 수: 1
Syed Abbas
Syed Abbas 2012년 1월 6일
thanks

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by