Matlab:如果解决方案表示为向量,如何针对特定x值绘制解决方案

时间:2015-02-12 09:44:07

标签: matlab matlab-figure

我使用pdenonlin求解器在2D空间域(x-y)中求解了非线性ODE。如何在特定的x值(比如x = 0.4)下将解决方案绘制为y的函数?谢谢

c = 1;
a = 0;
f = char('u');
d = 1; xmin=0;xmax=0.575;ymin=0;ymax=0.05315;ymax2=0.066; 
gdm = [3;4;xmin;xmax;xmax;xmin;ymax;ymax2;ymin;ymin]; 
g = decsg(gdm, 'S1', ('S1')');
hmax = .1; % element size
[p, e, t] = initmesh(g, 'Hmax', hmax);
[p,e,t] = refinemesh(g,p,e,t);
[p,e,t] = refinemesh(g,p,e,t);
[p,e,t] = refinemesh(g,p,e,t);
[p,e,t] = refinemesh(g,p,e,t);
[p,e,t] = refinemesh(g,p,e,t);
numberOfPDE = 1;
pb = pde(numberOfPDE);
% Create a geometry entity
pg = pdeGeometryFromEdges(g);
bc1 = pdeBoundaryConditions(pg.Edges(1),'u',100);
bc2 = pdeBoundaryConditions(pg.Edges(2),'u',66);
bc3 = pdeBoundaryConditions(pg.Edges(3),'u',11);
bc4 = pdeBoundaryConditions(pg.Edges(4),'g',0);
pb.BoundaryConditions = [bc1,bc2,bc3,bc4]; 
u = pdenonlin(pb,p,e,t,c,a,f, 'jacobian', 'lumped');
figure;
hold on
pdeplot(p, e, t, 'xydata', u, 'contour', 'off', 'colormap', 'jet(99)');
title 'chemical Diffusion, Steady State Solution'
xlabel 'X-coordinate, cm'
ylabel 'Y-coordinate, cm'

2 个答案:

答案 0 :(得分:1)

tri2grid在给定点评估解的插值:

x=0.4;
y=linspace(ymin,ymax);
ux=tri2grid(p,t,u,x,y);
plot(y,ux)
xlabel('y')
ylabel('u')
title('x=0.4')

答案 1 :(得分:0)

我自己没有工具箱,但应该这样做:

set(gca,'XLim',[0.4-eps 0.4+eps])
view(90,0)

想法是剪切轴以仅显示与x=0.4的交点,然后旋转视图以显示ZY平面。