Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 工程数学软件 > MATLAB论坛
MATLAB论坛 一切MATLAB相关问题在此讨论。
回复
 
主题工具 显示模式
旧 2008-03-14, 11:44   #1
dmarquis
初级会员
 
注册日期: 2008-03-14
年龄: 42
帖子: 3
声望力: 0
dmarquis 正向着好的方向发展
默认 [讨论]matlab解一维偏微分方程的讨论

(1)形如 du/dt + a*du/dx = v*du2/dx2(二次偏导数) 的一阶偏微分方程可用pde函数求解

如下例:
0<x<1,0<t<0.00006; 初值u(x,0) = 0;边值u(0,t)=1,u(1,t)=0;参数a=10000,v=1;
编程如下:
function pdexvv
m = 0;
x = linspace(0,1,101);
t = linspace(0,0.00006,501);
sol = pdepe(m,@pdexvvpde,@pdexvvic,@pdexvvbc,x,t);
u = sol(:,:,1);
figure
plot(x,u(end,,'-r')
title('Numerical solution and exact solution.')
xlabel('x')
ylabel('u(x,end)')
%----------------------------------------------
function [c,f,s] = pdexvvpde(x,t,u,DuDx)
c = 1;
f = DuDx;
s = -10000.*DuDx ;
%---------------------------------------------
function u0 = pdexvvic(x)
u0 = 0;
%----------------------------------------------
function [pl,ql,pr,qr] = pdexvvbc(xl,ul,xr,ur,t)
pl = ul-1;
ql = 0;
pr = ur;
qr = 0;
可以很方便的求解,但是对于含点源的问题,不知道能否用pde求解
即相对于(1)中的问题,方程右端多了一个源项SS(x0);
当x0=0.3时,SS=1;其他SS=0

初步编程如下:
function pdexvv
m = 0;
x = linspace(0,1,101);
SS = zeros(size(x));
N = length(x);
for n = 1:N
if x(n)==0.3;
SS(n) = 1.;
end
end
t = linspace(0,0.00006,501);
sol = pdepe(m,@pdexvvpde,@pdexvvic,@pdexvvbc,x,t,SS);
u = sol(:,:,1);
figure
plot(x,u(end,,'-r')
title('Numerical solution and exact solution.')
xlabel('x')
ylabel('u(x,end)')
%----------------------------------------------
function [c,f,s] = pdexvvpde(x,t,u,DuDx,SS)
c = 1;
f = DuDx;
s = -10000.*DuDx + SS ;
%---------------------------------------------
function u0 = pdexvvic(x)
u0 = 0;
%----------------------------------------------
function [pl,ql,pr,qr] = pdexvvbc(xl,ul,xr,ur,t)
pl = ul-1;
ql = 0;
pr = ur;
qr = 0;

但总调试不过去
报错如下
??? Input argument 'ss' is undefined.

Error in ==> C:\MATLAB6p5p1\work\pdexvvd.m (pdexvvpde)
On line 24 ==> s = -10000.*DuDx + ss ;

Error in ==> C:\MATLAB6p5p1\toolbox\matlab\funfun\pdepe.m
On line 238 ==> c = feval(pde,xi(1),t(1),U,Ux,varargin{:});

Error in ==> C:\MATLAB6p5p1\work\pdexvvd.m
On line 13 ==> sol = pdepe(m,@pdexvvpde,@pdexvvic,@pdexvvbc,x,t,ss);

请大家不吝指教
dmarquis 当前离线   回复时引用此帖
旧 2008-04-03, 16:44   #2
dmarquis
初级会员
 
注册日期: 2008-03-14
年龄: 42
帖子: 3
声望力: 0
dmarquis 正向着好的方向发展
默认

这个问题我想错了么?

有没有人愿意指点我,谢谢
dmarquis 当前离线   回复时引用此帖
旧 2008-04-03, 17:24   #3
watcher
高级会员
 
注册日期: 2008-04-02
年龄: 47
帖子: 175
声望力: 21
watcher 正向着好的方向发展
默认

取消pdexvvpde函数输入参量中对SS的声明,把点源函数的定义放到函数pdexvvpde里试试
watcher 当前离线   回复时引用此帖
旧 2008-04-10, 11:07   #4
dmarquis
初级会员
 
注册日期: 2008-03-14
年龄: 42
帖子: 3
声望力: 0
dmarquis 正向着好的方向发展
默认 感谢watcher

谢谢指教,该问题按照您的指点已解决
dmarquis 当前离线   回复时引用此帖
回复

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码


相似的主题
主题 主题作者 版面 回复 最后发表
【求助】MATLAB7.0安装!在线等 jiufeng2007 MATLAB论坛 3 2008-09-26 09:17
[求助]请求高手帮忙 bash2008 MATLAB论坛 0 2008-05-25 20:47
[求助]matlab与vc用引擎接口 lijian15555 MATLAB论坛 3 2008-04-27 22:14
[求助] 06104112 MATLAB论坛 1 2008-04-19 16:39
[资料]数学建模中的MATLAB程序在C语言下的实现 labfans MATLAB论坛 25 2008-03-10 21:58


所有时间均为北京时间。现在的时间是 21:34


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.