f



How do I create a diagonal matrix with block matricies on the diagonal?

Hello all,

I need to create a square matrix that has square block matricies
along the diagonal and zeros everywhere else. That is to say, I need
to create a block diagonal matrix where each submatrix is different.
The overall matrix needs to have the form:

M =
 - -
| sm1 0 0 |
| 0 sm2 0 |
| 0 0 sm3 |
 - -

Any advice would be greatly appreciated. Either post a reply or
email me directly(phatphreak74@yahoo.ca).

thanks in advance,
the phreak
0
8/15/2005 10:07:46 PM
comp.soft-sys.matlab 211266 articles. 19 followers. lunamoonmoon (257) is leader. Post Follow

2 Replies
521 Views

Similar Articles

[PageSpeed] 51

phat phreak wrote:
> Hello all,
> I need to create a square matrix that has square block matricies
> along the diagonal and zeros everywhere else.
> The overall matrix needs to have the form:
> 
> M =
>  - -
> | sm1 0 0 |
> | 0 sm2 0 |
> | 0 0 sm3 |
>  - -

hi friend,
maybe your problem can be solved by this:

 >> M=diag([2 6 8 9])

M =

      2     0     0     0
      0     6     0     0
      0     0     8     0
      0     0     0     9

it's very simple, diag(x), where x is a vector, return a matrix with x's 
  element on the diagonal and zeros everywhere else :P

www.vettigli.tk
0
Im1 (23)
8/15/2005 10:44:41 PM
phat phreak wrote:
>
>
> Hello all,
>
> I need to create a square matrix that has square block matricies
> along the diagonal and zeros everywhere else. That is to say, I
> need
> to create a block diagonal matrix where each submatrix is
> different.
> The overall matrix needs to have the form:
>
> M =
> - -
> | sm1 0 0 |
> | 0 sm2 0 |
> | 0 0 sm3 |
> - -
>
> Any advice would be greatly appreciated. Either post a reply or
> email me directly(phatphreak74@yahoo.ca).
>
> thanks in advance,
> the phreak

Hi!

Use blkdiag:

a=magic(2);
b=ones(2);
c=hankel(1:2);
D=blkdiag(a,b,c)

HTH

PB
0
PB
8/16/2005 5:42:17 AM
Reply:

Similar Artilces:

Creating a J*J Diagonal Matrix with Jth Diagonal element is also a matrix
Hello, I am a new beginner of Matlab and I want to create a Diagnoal Matrix with the main diagnoal as (A1,A2,A3,....,Aj) where Aj is also a matrix which is defined as (a11,a12,a13;a21,a22,a23;a31,a32,a33). How can I define Aj as a variable in the m file then create the diagnoal matrix through Aj? Could someone help on this please? Many Thanks in Advance! "Jie " <jz286@cam.ac.uk> wrote in message <h6selu$9ng$1@fred.mathworks.com>... > Hello, > > I am a new beginner of Matlab and I want to create a Diagnoal Matrix with the main diagnoal as (A1,A2,A3,....,Aj) w...

Create a block diagonal matrix from vectors
Hi, I'm a relatively new user in MATLAB and I'd appreciate if anyone can help me out with an answer or a reference on how to create block diagonal matrices from several vectors. As an example, if I have the following 4 vectors, d11=[1 5 9 13]; d12=[2 6 10 14]; d21=[3 7 11 15]; d22=[4 8 12 16]; what's the best way to create matrix D such that: D= 1 2 0 0 0 0 0 0 3 4 0 0 0 0 0 0 0 0 5 6 0 0 0 0 0 0 7 8 0 0 0 0 0 0 0 0 9 10 0 0 0 0 0 0 11 12 0 0 0 0...

Creating a sparse block diagonal matrix
Hi, does anyone know how to create what I think is called a sparse block diagonal matrix? Here is an example: I have one matrix that is sparse e.g. [1 0 0 0 ; 0 0 1 0 ; 0 0 1 0 ; 0 0 0 1 ] and want to create a new matrix where this matrix is repeted e.g. 10 times in the diagonal of a larger matrix i.e. a 40 x 40 matrix. How can I do this in a the most sparse and efficieant way? "Markus Nordberg" wrote in message <n7qmd3$3bc$1@newscl01ah.mathworks.com>... > Hi, > does anyone know how to create what I think is called a sparse block diagonal matrix? > ...

Block diagonal matrix from a skew-symmetric matrix
Dear Group members, I'm trying to solve the following algebra problem Consider a skew-symmetric matrix of the form: B=[0,A; -At,0] where 0 stands for a null matrix and At the transpose of matrix A. Is it possible to obtain a transformation of this matrix such as the new matrix in the new coordinates would be a block diagonal matrix of the form: C=[C1,0; 0,C2] with C=Tt * B * T, being T the transformation matrix? If possible how can I obtain such a transformation matrix? Thanks, RV ...

affecting a matrix rows as diagonal blocks in another matrix
Hi Suppose i have a matrix A= [1 4 5 8 7 3 6 5 2] I want to have a matrix B such each row of it has a row from A at the diagonal B=[1 4 5 0 0 0 0 0 0 0 0 0 8 7 3 0 0 0 0 0 0 0 0 0 6 5 2] how can i do it. I could do it with blkdiag but it supposes i input each row for the matrix, however i need something general since i need it for bigger matrices Thanks "matlab " <keep_smiling2100@yahoo.fr> wrote in message <jtkrgk$js0$1@newscl01ah.mathworks.com>... > Hi > Su...

block diagonal matrix
Hi all, Does anybody know what is the most efficient way to cobstruct a diagonal matrix from a vector of entries? For example I want to create: 1 0 0 0 2 0 0 0 3 from: a=1:3; "blkdiag" does not work here since I need to enter the vector elements one by one which I can't since "a" can be very large. Thanks, Elnaz On 9/5/2013 3:16 PM, Elnaz wrote: > Hi all, > > Does anybody know what is the most efficient way to cobstruct a diagonal ?matrix from a vector of entries? > For example I want to create: > 1 0 ...

creating a matrix from diagonals
This is quite a tricky for me. I need to construct a matrix A(a,b) where a>b. It will have a-b+1 number of diagonals containing b elements each. Where ith diagonal starting from (i,1) and ending (b+i-1,b) I have these diagonals with me. How do i construct this matrix A? I do not want to use spdiags(). I tried it and find it too expensive. mohitt wrote: > > > This is quite a tricky for me. > I need to construct a matrix A(a,b) where a>b. > It will have a-b+1 number of diagonals containing b elements each. > Where ith diagonal starting from (i,1) and ending (b+i-1,b) &...

creating diagonal matrix
Hi, Let say I have a vector B=[1 0] and I want to use this vector B repeating in this matrix A having size [8x16]. First, I initialize the matrix A with all zeros then I want to have the outcome as below: A= [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0]; How can I use that vector B repeat several times on matrix A using some code? It looks like an ...

Is a matrix block diagonal?
Hello, How would you find whether a given symmetric matrix is block diagonalizable (under shuffling of the indices)? My matrix is very large, binary and symmetric. It is not sparse, it has ~ 10% 1s. I want to find whether some indices cluster with others, or whether the whole thing is irreducible. Thanks, Pedro Pedro Bordalo wrote: > > > Hello, > > How would you find whether a given symmetric matrix is block > diagonalizable (under shuffling of the indices)? > > My matrix is very large, binary and symmetric. It is not sparse, > it > has ~ 10% 1s. I want to fi...

Block diagonal matrix construction
Suppose you have block A, B, C, ... How do you create a block diagonal matrix with blocks A, B, C, ... on the diagonal? Without looping through the elements of course. / Any ideas are much appreciated (google didn't help me) john wrote: > Suppose you have block A, B, C, ... How do you create a block diagonal > matrix with blocks A, B, C, ... on the diagonal? Without looping > through the elements of course. > > / Any ideas are much appreciated (google didn't help me) Does HELP BLKDIAG do what you want? -- Steve Lord slord@mathworks.com > &g...

To construct a block diagonal matrix
I have two qubit density operator which have an n term approaching to infinity. I want to construct density matrix from it. which is a block dioganal matrix.I have some problem to do so.. Any help? On 4/3/2013 3:11 AM, Niaz khan wrote: > I have two qubit density operator which have an n term approaching to > infinity. I want to construct density matrix from it. which is a block > dioganal matrix.I have some problem to do so.. Any help? >> lookfor diagonal blkdiag - Block diagonal concatenation of matrix input arguments. diag - Diagonal matrices and diagonals of...

creating a diagonal matrix with boundaries...
Dear all, I am no big Matlab expert and for some hours now, I have been struggling with this "simple" program. However, I can't figure it out... clear all N=5; boundary = 1; diag_coeff=[1 -1]; position=[-1]; values=[]; for number=1:size(diag_coeff,2) values(:,number) = ones(N,1).*diag_coeff(1,number); placement(1,number) = (position -1 + number); end if boundary == 1; % if ok, create boundary values(:,number+1)=ones(N,1).*diag_coeff(1,number); % left of diagonal placement(1,number+1) = (-N+(size(diag_coeff,2))-1); % left of diagonal values(:,number+...

construct diagonal block matrix
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? Tim Hi Tim, I have a solution. Let M = [1 2; 3 4; 5 6]; Then, the matrix you are looking for can be computed with the following two lines: A = [diag(M(:,1)) diag(M(:,2))]; B = A(:,reshape(reshape(1:6,3,2)',1,6)) Hope this helps, Danny "Tim Yang" <dlISCool@gmail.com> wrote in message <h0u...

Block matrix: off Diagonal Matrices
Please Steve, you didn't tell how I can get the off diagonal matrices? The 2D laplacian matrix has off diagonal matrices of (alpha)I where I is identity matrix of the same dimension as the diagonal matrix. final matix: A = |B1 (a1)I ........ ... | |(a2) B2 (a2)I ........ | |....(a3)I B2 (a3)I ...| |.... ... ... | | (an)I Bn | Your help will be much appreciated! cheers E4Home wrote: > Please Steve, you didn't tell how I can get the off diagonal > matrices? The 2D laplacian matrix has off diagonal matrices of &g...

Web resources about - How do I create a diagonal matrix with block matricies on the diagonal? - comp.soft-sys.matlab

088/365 More maths today - Flickr - Photo Sharing!
Carrying on from yesterdays shot I went to the maths dept today to do the algebra assignment. After much reading and starring and working out ...

Betweenness centrality - Wikipedia, the free encyclopedia
Betweenness centrality is a measure of a node's centrality in a network . It is equal to the number of shortest paths from all vertices to all ...

An Overview of Matrix Mechanics
Because of Heisenberg's assertion regarding the commutation relation between certain variables it is obvious that the properties of particles ...

64x32 RGB LED Matrix - 5mm pitch ID: 2277 - $79.95 : Adafruit Industries, Unique & fun DIY electronics ...
Adafruit Industries, Unique & fun DIY electronics and kits 64x32 RGB LED Matrix - 5mm pitch ID: 2277 - Bring a little bit of Times Square into ...

Theory of Mind vs. Theory of Reality: The tradeoff along the Autism Spectrum
In any great organization it is far, far safer to be wrong with the majority than to be right alone. John Kenneth Galbraith If the only tool ...

Clock/Visualizer Shield
Checkout this video of the shield in action! Please note that the shield is on a glass table in the video. This

The Mp3 Garbler
An led display, 140 of them to be exact. Though, this wasn’t as difficult as it sounds. I used 4 5×7 led matricies with a max6953 chip which ...

site map - Golf Fitness Training Programs at FitGolf Performance Centers
The Golf Fitness Experts training, online training, franchising and pod casts on a variety of topics including the body, injuries, mental game, ...

The Square Inch Project
... Their construction is actually pretty simple, it’s just an LED array with a mask of letters. Usually word clocks are large, but 8×8 LED matricies ...

Prime numbers News, Videos, Reviews and Gossip - io9
Have mathematicians finally discovered the hidden relationship between prime numbers?. The bizarre mathematical conundrum of Ulam's Spiral. Take ...

Resources last updated: 2/3/2016 12:05:17 AM