Is this what you are looking for?
xmax=1; ymax=7; m=20; n=29; tmax=100; nt=500;
dx=xmax/m; dy=ymax/n; dt=tmax/nt;
UOLD=zeros(m,n);VOLD=zeros(m,n);
A=zeros([m,m]);
B=A;
C=A;
while dt<tmax
for j=1:n
for i=1:m
if j>i
C(j-1,j)=((dt*VOLD(i,j))/(4*dy))-(dt/(2*(dy^2))); %superdiagonal
elseif i>j
A(i,i-1)=((-dt*VOLD(i,j))/(4*dy))-(dt/(2*(dy^2))); %sub diagonal
elseif i==j
B(i,j)=1+((dt*UOLD(i,j))/(2*dx))+(dt/(dy^2)); %main diagonal
end
end
end
dt=0.2+dt;
end
A
A = 20×20
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
-856.4469 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 -856.4469 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 -856.4469 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 -856.4469 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 -856.4469 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 -856.4469 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 -856.4469 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 -856.4469 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 -856.4469 0 0 0 0 0 0 0 0 0 0 0
B
B = 20×20
1.0e+03 *
1.7139 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1.7139 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1.7139 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1.7139 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1.7139 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1.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