| MATLAB Central > MATLAB Newsreader > construct diagonal block matrix |
|
|
|
Subject: construct diagonal block matrix From: Tim Yang Date: 12 Jun, 2009 21:58:01 Message: 1 of 20 |
|
I want to build a diagonal matrix such as |
|
Subject: construct diagonal block matrix From: Danny Klein Date: 20 Aug, 2009 20:08:04 Message: 2 of 20 |
|
Hi Tim, |
|
Subject: construct diagonal block matrix From: Bruno Luong Date: 20 Aug, 2009 20:24:19 Message: 3 of 20 |
|
"Tim Yang" <dlISCool@gmail.com> wrote in message <h0uj19$i02$1@fred.mathworks.com>... |
|
Subject: construct diagonal block matrix From: Danny Klein Date: 20 Aug, 2009 20:38:23 Message: 4 of 20 |
|
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <h6kbdj$b2k$1@fred.mathworks.com>... |
|
Subject: construct diagonal block matrix From: Bruno Luong Date: 20 Aug, 2009 20:39:21 Message: 5 of 20 |
|
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <h6kbdj$b2k$1@fred.mathworks.com>... |
|
Here's a solution that meets the stated requirements, but I don't know if it saves anything. It uses kron, which is generally a slow operation |
|
Subject: construct diagonal block matrix From: Bruno Luong Date: 20 Aug, 2009 20:47:04 Message: 7 of 20 |
|
M = [1 2; 3 4; 5 6]; |
|
Subject: construct diagonal block matrix From: Bruno Luong Date: 20 Aug, 2009 20:50:23 Message: 8 of 20 |
|
> |
|
Subject: construct diagonal block matrix From: Danny Klein Date: 20 Aug, 2009 20:50:24 Message: 9 of 20 |
|
"Matt " <xys@whatever.com> wrote in message <h6kcbr$c3k$1@fred.mathworks.com>... |
|
"Matt " <xys@whatever.com> wrote in message <h6kcbr$c3k$1@fred.mathworks.com>... |
|
Subject: construct diagonal block matrix From: Bruno Luong Date: 20 Aug, 2009 21:11:19 Message: 11 of 20 |
|
This should be pretty fast: |
|
Subject: construct diagonal block matrix From: Danny Klein Date: 20 Aug, 2009 21:17:23 Message: 12 of 20 |
|
"Matt " <xys@whatever.com> wrote in message <h6kcvo$mkl$1@fred.mathworks.com>... |
|
Subject: construct diagonal block matrix From: Bruno Luong Date: 20 Aug, 2009 21:19:04 Message: 13 of 20 |
|
% Sorry make it: |
|
"Danny Klein" <djklein.dont.include.this.part@gmail.com> wrote in message <h6kcug$k3q$1@fred.mathworks.com>... |
|
Subject: construct diagonal block matrix From: Danny Klein Date: 20 Aug, 2009 21:22:03 Message: 15 of 20 |
|
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <h6ke5n$8sf$1@fred.mathworks.com>... |
|
Subject: construct diagonal block matrix From: Bruno Luong Date: 20 Aug, 2009 21:28:04 Message: 16 of 20 |
|
"Danny Klein" <djklein.dont.include.this.part@gmail.com> wrote in message <h6kepr$knh$1@fred.mathworks.com>... |
|
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <h6kek8$9o4$1@fred.mathworks.com>... |
|
Subject: construct diagonal block matrix From: Bruno Luong Date: 20 Aug, 2009 21:36:03 Message: 18 of 20 |
|
"Matt " <xys@whatever.com> wrote in message <h6kf7g$hq4$1@fred.mathworks.com>... |
|
Subject: construct diagonal block matrix From: Danny Klein Date: 20 Aug, 2009 21:48:47 Message: 19 of 20 |
|
For small problems, it would seem that my original approach works faster than the sparse methods you guys have suggested. I suppose the added overhead of sparse manipulation doesn't pay off. For the size of the matrix in the original post by Tim (3x2), my method gives about 0.000998 sec whereas both of Matt's give about 0.0017 sec. All of these times are super small, so it probably doesn't matter. I think Tim was just looking for _any_ way to compute the answer. |
|
"Danny Klein" <djklein.dont.include.this.part@gmail.com> wrote in message <h6kgbv$mt$1@fred.mathworks.com>... |
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
| Tag Activity for This Thread | ||
|---|---|---|
| Tag | Applied By | Date/Time |
| diagonal block ... | Diego Lass | 12 Jun, 2009 17:59:05 |
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.
Contact us at files@mathworks.com