Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: spdiags() “Index exceeds matrix dimensions.”ask for help??
Replies: 1   Last Post: Nov 18, 2012 11:53 PM

 Messages: [ Previous | Next ]
 dfd ssss Posts: 2 Registered: 11/17/12
spdiags() “Index exceeds matrix dimensions.”ask for help??
Posted: Nov 18, 2012 1:34 PM

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);

Date Subject Author
11/18/12 dfd ssss
11/18/12 Steven Lord