Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: construct diagonal block matrix
Date: Thu, 20 Aug 2009 20:24:19 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 19
Message-ID: <h6kbdj$b2k$1@fred.mathworks.com>
References: <h0uj19$i02$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1250799859 11348 172.30.248.38 (20 Aug 2009 20:24:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 20 Aug 2009 20:24:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:564884


"Tim Yang" <dlISCool@gmail.com> wrote in message <h0uj19$i02$1@fred.mathworks.com>...
> I want to build a diagonal matrix such as
> 
> 1 2 0 0 0 0
> 0 0 3 4 0 0 
> 0 0 0 0 5 6 
> 
> with a given (arbitrary) matrix,   
> 1 2
> 3 4
> 5 6
> 
> without using loops and cell arrays (conversion takes time)  blkdiag works with only parameters (a,b,c,d...) a,b,c,d... are row vectors.
> suggestions?
> 

spdiags(M,[0 1],3,4)

% Bruno