Prev: merge two diagonal matrix
Next: Memory issue with large matrix multiplication, only one row of result needed
From: dafina on 7 Apr 2010 19:08 How can I merge two diagonal matrix in matlab wtih different dimensions, for example the first one is 6x6 and dhe second is 194x194, in one that is 200x200 thnx
From: Nathan on 7 Apr 2010 19:08 On Apr 7, 4:02 pm, "dafina " <d.xh...(a)gmail.com> wrote: > how can I merge in matlab two diagonal matrix with different dimensions, for example the first is 6 x 6, and the second is 194x194, in one diagonal matrix with dimension 200x200. > > thnx Try BLKDIAG Assume A is your 6x6 matrix and B is your 194x194 matrix: C = blkdiag(A,B); C is now the 200x200 diagonal matrix that consists of the diagonals A and B. -Nathan
From: dafina on 7 Apr 2010 19:22 Nathan <ngreco32(a)gmail.com> wrote in message <e538a2cb-6542-4ac8-967d-e0600a41d394(a)z7g2000yqb.googlegroups.com>... > On Apr 7, 4:02 pm, "dafina " <d.xh...(a)gmail.com> wrote: > > how can I merge in matlab two diagonal matrix with different dimensions, for example the first is 6 x 6, and the second is 194x194, in one diagonal matrix with dimension 200x200. > > > > thnx > > Try BLKDIAG > > Assume A is your 6x6 matrix and B is your 194x194 matrix: > > C = blkdiag(A,B); > > C is now the 200x200 diagonal matrix that consists of the diagonals A > and B. > > -Nathan Thnx Nathan But this create a matrix with diagonal elements in block form, i want that the diagonal elements from 1 to 6, to have the value of the diagonal elements of first matrix and from 6 to 200 the diagonal elements of the second matrix, just the diagonal elements and the other there will be zero. in total this matrix will be 200x200.
From: Matt Fig on 7 Apr 2010 19:46 % Data A = diag(rand(1,2)) B = diag(rand(1,4)) % Engine C = diag([diag(A),diag(B)]) % Also could index by A(1:size(A,1)+1:end)
From: Sean on 8 Apr 2010 08:17 "dafina " <d.xhako(a)gmail.com> wrote in message <hpj38j$h12$1(a)fred.mathworks.com>... > How can I merge two diagonal matrix in matlab wtih different dimensions, for example the first one is 6x6 and dhe second is 194x194, in one that is 200x200 a = magic(6) b = magic(20) c = [a zeros(size(a,1),size(b,2)); zeros(size(a,1),size(b,2))' b]
|
Next
|
Last
Pages: 1 2 Prev: merge two diagonal matrix Next: Memory issue with large matrix multiplication, only one row of result needed |