Plotting the solution to the Laplace equation

조회 수: 43 (최근 30일)
Briyahna Deleon
Briyahna Deleon 2019년 4월 7일
답변: Agnish Dutta 2019년 4월 11일
Hi guys, I am trying to plot the solution to a PDE. I was given the laplace equation where u(x,y) is
L= pi, and H= pi/4. I want to plot the solution in 2D. This is what I have so far.
for c = 1:10
g = sin(pi.*c);
for n=1: 10
L = pi;
H= L/4;
for x = 0:L
integral = g*sin((n.*pi.*x)/L);
end
an = 2/(n.*pi*sinh((n.*pi*H)/2)).*integral;
uxy = an*sin((n.*pi.*c)/L)*cosh(n.*pi*(y-H)/2);
end
end
figure;
plot(x,uxy)
When I run it, it gives me a blank plot. Any tips on how to fix this or fix some of my coding errors? It would be much appreciated!
  댓글 수: 1
A. Sawas
A. Sawas 2019년 4월 7일
편집: A. Sawas 2019년 4월 7일
You are not keeping the interim results in the two loops you have in the code. Eventually, (x, uxy) is a single point.
Try this to see this point:
plot(x,uxy, '+');

댓글을 달려면 로그인하십시오.

답변 (1개)

Agnish Dutta
Agnish Dutta 2019년 4월 11일
I suggest using the symbolic mathematics toolbox which provides functions for solving, plotting, and manipulating symbolic math equations.
"u(x, y)" seems like a bivariate function. To plot such a function, have a look at the "Generate surfaces z=f(x,y) without meshgrid" section of the following document:
You will find multiple other tools for plotting functions of different types in the above page.
Also, please have a look at the following MATLAB answers page containing a similar problem:

카테고리

Help CenterFile Exchange에서 Geometry and Mesh에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by