I have a problem with plotting a summation equation

1 次查看(过去 30 天)
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

采纳的回答

Mitch Martelli
Mitch Martelli 2012-11-27
编辑:Mitch Martelli 2012-11-27
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)
  1 个评论
Sherman
Sherman 2012-11-27
编辑:Sherman 2012-11-27
sorry, i wasnt clear, but i have to find the summation for n:0-25. Thanks, this is helping. The assignment says plot g(x,y) using mesh(y,x,g(x,y)).

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by