```Date: Nov 17, 2012 11:02 PM
Author: dfd ssss
Subject: need help of block tridiagonal matrix???

I want to create a block tridiagonal matrix,so I used spdiags(),however, everytime I receive the "Error using horzcat CAT arguments dimensions are not consistent.Error in spdiags (line 114) a((len(k)+1):len(k+1),:) = [i i+d(k) B(i+(m>=n)*d(k),k)];"I don't know why, hope someone can give me a hand, thanks!clc;clear;NT=10;Len=15;lm=0.1;t=1;T=5;MT=500;detX=Len/NT;  % at detT time how many detX should be,to some extent, it is fixed.detT=T/MT;  %control how many times to do this systemFu=zeros(1,NT-1);Fv=zeros(1,NT-1);u=zeros(1,NT-1); i=1;while i<=NT-1;       %X=i*detX;    %T=i*detT;    u(i) = (i/NT)*(1-i/NT)*exp (10*(i/NT-1));%  u[i]=(i/N)*(1-i/N)*(exp (-10*(i/N)));%  u[i]=(0.1)*(1+ cos (360.0*PI*(i/N-0.5)/180));i=i+1;endvpa(u,10)disp('u=');disp(u);%uv=zeros(1,NT-1);i=1;while i<=NT-1;v(i) = (i/NT)*(1-i/NT)*exp (-10*(i/NT));%v[i]=(i/N)*(1-i/N)*(exp (10*(i/N-1)));%v[i]=(0.1)*(1+ cos (360.0*PI*(i/N-0.5)/180));i=i+1;endvpa(v,10)disp('v=');disp(v);%vM = cell(1,NT-1);for i = 1:NT-1 % L changable parameter        M{i} = [(1+(detT/(5*detX*detX))-detT+2*detT*u(i)+4*detT*v(i)),(4*detT*u(i));(-4*detT*v(i)),(1+2*detT/(detX*detX)+0.25*detT-4*detT*u(i)+5*detT*lm*exp(-5*v(i)))];        enddisp(blkdiag(M{:}));%disp(size(M{1}));UP = cell(1,NT-1);for i = 1:NT-1 % L changable parameter        UP{i} =[-detT/(10*detX*detX),0;0,-detT/(detX*detX)];        endDOWN=cell(1,NT-1);for i = 1:NT-1 % L changable parameter        DOWN{i} =[-detT/(10*detX*detX),0;0,-detT/(detX*detX)];        endRR=spdiags(M{i},0,NT-1);disp(RR);%A = blktridiag(DOWN{i},M{i},UP{i},NT-1);%+blkdiag(M{:});A = spdiags(repmat([DOWN M UP],NT,1),-1:1,NT,NT);vpa(A,10)disp(A);
```