필터 지우기
필터 지우기

I have a problem with plotting a summation equation

조회 수: 1 (최근 30일)
Sherman
Sherman 2012년 11월 27일
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