Combining Matrices
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Respuesta aceptada
Andrei Bobrov
el 6 de En. de 2012
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
>>
Más respuestas (0)
Ver también
Categorías
Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!