花如月 发表于 2007-7-12 18:52

多亏了各位的帮忙啊,总算是做出来一个简单的:
function shuzhi
m = 0;
z = linspace(0,6,20);%轴向长度
t = linspace(0,50,5);%时间刻度

sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,z,t);
% Extract the first solution component as u.
c = sol(:,:,1);

% A surface plot is often a good way to study a solution.
surf(z,t,c)   
title('Numerical solution computed with 20 mesh points.')
xlabel('Distance z')
ylabel('Time t')

% A solution profile can also be illuminating.
figure
plot(z,c(end,:))
title('Solution at z = 2')
xlabel('Distance z')
ylabel('c(z,2)')
% --------------------------------------------------------------
function = pdex1pde(x,t,c,DcDz)
T=298;%环境温度(室温)
D = 396*(T/273)^1.75;%水分扩散系数
f = DcDz;
s = 0;
% --------------------------------------------------------------
function c0 = pdex1ic(x)
c0 = 34.37;%初始水分含量
% --------------------------------------------------------------
function = pdex1bc(xl,ul,xr,ur,t)
a=0.355;%轴向扩系系数
pl = ul;
ql = 0;
pr = a*(34.37-11.20)/461.6*exp(-t);
qr = 6;

文件存成shuzhi.m在命令行键入shuzhi就会有结果并绘图。不过发现一个问题:

m = 0;
z = linspace(0,6,20);%轴向长度
t = linspace(0,50,5);%时间刻度
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,z,t);
% Extract the first solution component as u.
c = sol(:,:,1);
% A surface plot is often a good way to study a solution.
surf(z,t,c)   
title('Numerical solution computed with 20 mesh points.')
xlabel('Distance z')
ylabel('Time t')
% A solution profile can also be illuminating.
figure
plot(z,c(end,:))
title('Solution at z = 2')
xlabel('Distance z')
ylabel('c(z,2)')
把这段代码复制粘贴到命令行,也能运行。照理说结果应该一样才对啊,可是实际上得出的曲线却完全不一样!高手给找一下看是什么原因、、

gghhjj 发表于 2007-7-13 06:24


pdex1pde
pdex1ic
pdex1bc

这三个函数单独存成三个文件就可以了

jongta 发表于 2007-12-3 21:44

本来想把《偏微分方程的MATLAB解法》的电子版传上去,可是还想不能上传,说文件格式不对

chuandong418 发表于 2009-7-10 08:25

请有这本书的朋友,能不能给我也传一份啊?我的邮箱是:wangyinding@163.com

liuxing28 发表于 2009-9-25 17:30

多谢
也给我传一本吧
我的邮箱liuxing28@126.com
感激

baolei241 发表于 2009-10-14 10:46

《偏微分方程的MATLAB解法》
有这本书的朋友,麻烦也给我传一份吧,我要解一个非线性方程组。谢谢!
baolei241@163.com
页: 1 [2]
查看完整版本: 经典偏微分方程求解的问题