I'm plotting a solution to a PDE using surf but the graph turns out wrong?
Mostrar comentarios más antiguos
I'm trying to plot the solution to a PDE, which is an infinite series:
So far this is my code, I can't see what's wrong with it. I've attached the graph i got below.
edit: the sin part is part of the summation, and the original pde is:


xRange = 0:0.1:6;
tRange = 0:0.1:6;
[x,t] = meshgrid(xRange,tRange);
u = zeros(size(x));
for n=1:300
u = u+(4/(n^3*pi^3)+(4/(n*pi)-4/(n^3*pi^3))*exp(-n^2*pi^2.*t)).*sin(n*pi/2*x);
end
surf(x,t,u);
xlabel("X");
ylabel("T");
zlabel("U");
Respuesta aceptada
Más respuestas (2)
Max Heiken
el 10 de Jun. de 2021
Editada: Max Heiken
el 10 de Jun. de 2021
The part with the sin is missing in your code.
for n=1:10
u = u+(4/(n^3*pi^3)+(4/(n*pi)-4/(n^3*pi^3))*exp(-n^2*pi^2*t)).*sin(n*pi*x/2);
end
surf(x,t,u);
edited: It seems like the sin part is supposed to be part of the summation.
1 comentario
Vicky Ngo
el 10 de Jun. de 2021
Categorías
Más información sobre Geometry and Mesh en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
