MATLAB: I have a problem with plotting a summation equation

MATLABsummation; multivariate

The question: For the fuction:
g(x,y) = G=4*sum((1-cos(n*pi)./(n*pi).^3).*exp(-n*pi*x).*sin(n*pi*y)).
y is between 0 and 1 and x is o to .7. We must use increment of 0.05 for x and 0.025 for y and n=25. I have to plot g using mesh(y,x,G). Heres what i got:
X=linspace(0,0.7,14);
Y=linspace(0,1,40);
X=Y.';
[x,y]=meshgrid(X,Y);
for n=1:25;
G=4*sum((1-cos(n*pi)./(n*pi).^3).*exp(-n*pi*x).*sin(n*pi*y));
mesh(G)
end

Best Answer

Hi, you mean something like that ?
y=0:0.025:1;
x=0:0.05:0.7;
n=1:1:50;
[X,Y]=meshgrid(x,y);
for i=1:size(n,2)
g_n=4*sum(1-cos(n(i)*pi)/(n(i)*pi)^3)*exp(-n(i)*pi*X).*sin(n(i)*pi*Y);
g_xy(:,:,i)=g_n;
end
G=sum(g_xy,3);
mesh(X,Y,G)