Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: help with blkdiag()
Date: Fri, 12 Jun 2009 21:52:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 18
Message-ID: <h0uim1$p9e$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1244843521 25902 172.30.248.35 (12 Jun 2009 21:52:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 12 Jun 2009 21:52:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1875128
Xref: news.mathworks.com comp.soft-sys.matlab:547045


I have a 2D matrix 

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

I want to create a diagonal matrix without using loops and using blkdiag()
ie matrix
  1   2   3  4   5                                         alll zero
  0   0   0  0   0   6   7   8   9  10
  0   0   0  0   0   0   0   0   0    0  11 12 13 14 15
  0   0   0  ...                                                      16 17 18 19 20

I don't want to convert it to cell array (because the matrix is large, conversion is time consuming).  blkdiag()  only accept ( row vector, row vector...)

Thanks
Tim