help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

block version of diag function


From: Kamaraju S Kusumanchi
Subject: block version of diag function
Date: Thu, 06 Mar 2008 11:24:53 -0500
User-agent: KNode/0.10.4

1) If I have a matrix such as

octave:1> A = [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16]
A =

    1    2    3    4
    5    6    7    8
    9   10   11   12
   13   14   15   16


diag(A) gives the diagonal elements of A. Is there any function in octave
which will give the block diagonals of specified size.

In the above example diag(A) gives

octave:2> diag(A)
ans =

    1
    6
   11
   16


I am looking for something that will output

 1  2  0  0
 5  6  0  0
 0  0 11 12
 0  0 15 16


2) Is there any way to assemble a set of blocks along the diagonals of a
bigger matrix.

For example if the inputs are

1 2
5 6

and

11 12
15 16

I would like to assemble these matrices along the diagonal and get

 1  2  0  0
 5  6  0  0
 0  0 11 12
 0  0 15 16


Currently I have my own code for doing this. But wondering if there are any
octave specific functions I am missing.


thanks
raju
-- 
Kamaraju S Kusumanchi
http://www.people.cornell.edu/pages/kk288/
http://malayamaarutham.blogspot.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]