<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/253582</link>
    <title>MATLAB Central Newsreader - help with blkdiag()</title>
    <description>Feed for thread: help with blkdiag()</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 12 Jun 2009 21:52:01 -0400</pubDate>
      <title>help with blkdiag()</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/253582#656897</link>
      <author>Tim Yang</author>
      <description>I have a 2D matrix &lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;1   2   3  4   5&lt;br&gt;
&amp;nbsp;&amp;nbsp;6   7   8  9  10&lt;br&gt;
&amp;nbsp;11 12 13 14 15&lt;br&gt;
&amp;nbsp;16 17 18 19 20&lt;br&gt;
&lt;br&gt;
I want to create a diagonal matrix without using loops and using blkdiag()&lt;br&gt;
ie matrix&lt;br&gt;
&amp;nbsp;&amp;nbsp;1   2   3  4   5                                         alll zero&lt;br&gt;
&amp;nbsp;&amp;nbsp;0   0   0  0   0   6   7   8   9  10&lt;br&gt;
&amp;nbsp;&amp;nbsp;0   0   0  0   0   0   0   0   0    0  11 12 13 14 15&lt;br&gt;
&amp;nbsp;&amp;nbsp;0   0   0  ...                                                      16 17 18 19 20&lt;br&gt;
&lt;br&gt;
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...)&lt;br&gt;
&lt;br&gt;
Thanks&lt;br&gt;
Tim</description>
    </item>
    <item>
      <pubDate>Fri, 12 Jun 2009 22:08:01 -0400</pubDate>
      <title>Re: help with blkdiag()</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/253582#656911</link>
      <author>Bruno Luong</author>
      <description>A = [1 2 3 4 5;&lt;br&gt;
&amp;nbsp;&amp;nbsp;6 7 8 9 10;&lt;br&gt;
&amp;nbsp;11 12 13 14 15;&lt;br&gt;
&amp;nbsp;16 17 18 19 20 ];&lt;br&gt;
&lt;br&gt;
I = repmat((1:size(A,1)), size(A,2),1);&lt;br&gt;
J = 1:numel(A);&lt;br&gt;
B = accumarray([I(:) J(:)],reshape(A.',[],1)) % sparse is even better</description>
    </item>
  </channel>
</rss>

