MATLAB: Mesh plot for a series equation

mesh plot

Error using mesh (line 76),Z must be a matrix, not a scalar or vector. Can anyone please sort out for me the possible solution? Thanks in advance
L=2;
W=2;
x=0:0.2:2;
y=0:0.2:2;
T1=70;
T2=200;
n=1:0.2:1000;
[X,Y]=meshgrid(x,y);
for i=1:length(n);
g_n=2/pi*sum(2/n(i)*sin(n(i)*pi*X/L).*sinh(n(i)*pi*Y/L)/sinh(n(i)*pi*W/L)));
end
Z=(T2-T1)*sum(g_n)+T1;
mesh(X,Y,Z)

Best Answer