Let\'s say I\'ve got a vector like this one:
A = [101:105]
Which is really:
[ 101, 102, 103, 104, 105 ]
And I
The best solutions are listed by Loren. It's also possible to create these matrices using SPDIAGS:
vec = 101:105;
A = full(spdiags(repmat(vec,5,1),0:4,5,5)); % The second matrix
B = fliplr(full(spdiags(repmat(fliplr(vec),5,1),0:4,5,5))); % The first matrix
I recall creating banded matrices like this before I found out about some of the built-in functions Loren mentioned. It's not nearly as simple and clean as using those, but it worked. =)