Thread Subject: Forming Sparse Banded Matrices

Subject: Forming Sparse Banded Matrices

From: Mohammad Tabesh

Date: 16 Jul, 2011 18:48:30

Message: 1 of 2

Hi all,

I'm trying to form a sparse banded matrix from a row vector a=1:3 as full(B) looks like:

[1 2 3 0 0 0 0 0 0 0 0 0;
 0 0 0 1 2 3 0 0 0 0 0 0;
 0 0 0 0 0 0 1 2 3 0 0 0;
 0 0 0 0 0 0 0 0 0 1 2 3]

and then what if I want to replicate A=[1 2 3; 4 5 6] with the same style in a way that full(B) looks like:

[1 2 3 0 0 0 0 0 0 0 0 0;
 4 5 6 1 2 3 0 0 0 0 0 0;
 0 0 0 4 5 6 1 2 3 0 0 0;
 0 0 0 0 0 0 4 5 9 1 2 3;
 0 0 0 0 0 0 0 0 0 4 5 6]

I don't want to build the full matrix because of the size of a and A and I'm trying to use spdiags but no success.

Regards

Subject: Forming Sparse Banded Matrices

From: Matt J

Date: 16 Jul, 2011 19:06:07

Message: 2 of 2

"Mohammad Tabesh" <osmikh@yahoo.com> wrote in message <ivsmdu$4cg$1@newscl01ah.mathworks.com>...
> Hi all,
>
> I'm trying to form a sparse banded matrix from a row vector a=1:3 as full(B) looks like:
>
> [1 2 3 0 0 0 0 0 0 0 0 0;
> 0 0 0 1 2 3 0 0 0 0 0 0;
> 0 0 0 0 0 0 1 2 3 0 0 0;
> 0 0 0 0 0 0 0 0 0 1 2 3]
==============

This is simply

Nrows=4;
T=kron(speye(Nrows),[1 2 3]),




>
> and then what if I want to replicate A=[1 2 3; 4 5 6] with the same style in a way that full(B) looks like:
>
> [1 2 3 0 0 0 0 0 0 0 0 0;
> 4 5 6 1 2 3 0 0 0 0 0 0;
> 0 0 0 4 5 6 1 2 3 0 0 0;
> 0 0 0 0 0 0 4 5 9 1 2 3;
> 0 0 0 0 0 0 0 0 0 4 5 6]
================

This can be done with my interpMatrix tool

http://www.mathworks.com/matlabcentral/fileexchange/26292-regular-control-point-interpolation-matrix-with-boundary-conditions

as follows,

kernel=[4 5 6 1 2 3];
origin=4;
Nrows=5;

T=interpMatrix(kernel,origin,Nrows,3).';
T(:,end)=[],


But it's hard to know how general you want to get with this....

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

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
interpmatrix Matt J 16 Jul, 2011 15:32:09
block toeplitz Matt J 16 Jul, 2011 15:32:01
banded sparse m... Mohammad Tabesh 16 Jul, 2011 14:49:13
replicate Mohammad Tabesh 16 Jul, 2011 14:49:13
spdiags Mohammad Tabesh 16 Jul, 2011 14:49:13
sparse Mohammad Tabesh 16 Jul, 2011 14:49:13
rssFeed for this Thread

Contact us at files@mathworks.com