Plot solution of pde toolbox on a line (or submanifold)
조회 수: 3 (최근 30일)
이전 댓글 표시
I'm using the pde toolbox to solve a certain elliptic equation in 2D.
Solution is fine, although I do need to plot it along a given line, i.e. to cut a planar slice from the 3D mesh representing the solution.
I can't figure out a way that smartly involves the toolbox functions.
Any help appreciated.
댓글 수: 0
채택된 답변
Bill Greene
2012년 11월 2일
Hi,
Here is one way to create such a plot. Assume you have the point matrix created by the PDE Toolbox mesher, p, and a solution vector, u. The function below will create a plot of that solution along a line defined by the x and y locations of the two end points. My example is for a solution on a unit square and I want a plot along the line (0,.5) to (1,.5). I want to include 25 points in the plot. As you can see, the real work is being done by the TriScatteredInterp function from core MATLAB.
plotAlongLine(p, u, [0,.5], [1,.5], 25);
function plotAlongLine(p, u, xy1, xy2, numpts)
x = linspace(xy1(1),xy2(1),numpts);
y = linspace(xy1(2),xy2(2),numpts);
F = TriScatteredInterp(p(1,:)', p(2,:)', u);
uxy = F(x,y);
figure; plot(x, uxy);
end
Bill
댓글 수: 13
Lukasz
2025년 4월 22일
One more question.
How can I export any variables calculated in the function to an external file, especially the data used to create a chart?
Torsten
2025년 4월 22일
편집: Torsten
2025년 4월 22일
timestep = 4;
numpts = 25;
pstart = [0 0];
pend = [1 3];
[x,y,uxy] = plotAlongLine(p, u, pstart, pend, numpts, timestep);
plot(sqrt(x.^2+y.^2),uxy)
writematrix([(sqrt(x.^2+y.^2)).',uxy.'],'Results.xls')
function [x,y,uxy] = plotAlongLine(p, u, xy1, xy2, numpts, timestep)
x = linspace(xy1(1),xy2(1),numpts);
y = linspace(xy1(2),xy2(2),numpts);
F = TriScatteredInterp(p(1,:)', p(2,:)', u(:,timestep));
uxy = F(x,y);
end
추가 답변 (1개)
Lukasz
2025년 5월 7일
New task and I found a new problem. :(
Problem with determining the temperature on the line with endpoints at points A(0;0) and B(0.88; 5) - the left side of the polygon.
The simulation is about heat transfer.
In the simple example I asked about in previous posts, which is above, everything works.
Details of the problem are in the pdf file.
Please, I ask for your help.
Luk.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 PDE Solvers에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!