Filter löschen
Filter löschen

I have a problem with plotting a summation equation

1 Ansicht (letzte 30 Tage)
Sherman
Sherman am 27 Nov. 2012
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

Akzeptierte Antwort

Mitch Martelli
Mitch Martelli am 27 Nov. 2012
Bearbeitet: Mitch Martelli am 27 Nov. 2012
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 Kommentar
Sherman
Sherman am 27 Nov. 2012
Bearbeitet: Sherman am 27 Nov. 2012
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)).

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by