Date: Nov 18, 2012 1:34 PM
Author: dfd ssss
Subject: spdiags() “Index exceeds matrix dimensions.”ask for help??

I just want to form a block tridiagonal matrix(DOWN is sub M in the middle,UP is sup),however, every time I used spdiags() ,it gave me a message ?Index exceeds matrix dimensions.?,I don't know why and I'm a beginner of matlab,hopefully, someone can give me a hand,thank you very much!

M = cell(1,NT-1);

for i = 1:NT-1

M{i} = [(1+(detT/(5*detX*detX))-detT+2*detT*u(i)+4*detT*v(i))-1,(4*detT*u(i))-1;(-4*detT*v(i))-1,(1+2*detT/(detX*detX)+0.25*detT-4*detT*u(i)+5*detT*lm*exp(-5*v(i)))-1];

end
LK = cell(1,NT-1);
for i = 1:NT-2
LK{i}=[1,1;1,1];
end



UP = cell(1,NT-1);
for i = 1:NT-1

UP{i} =[-detT/(10*detX*detX),0;0,-detT/(detX*detX)];

end

DOWN=cell(1,NT-1);
for i = 1:NT-2

DOWN{i} =[-detT/(10*detX*detX),0;0,-detT/(detX*detX)];

end
A = spdiags([DOWN M UP],-1:1,NT-1,NT-1);