多亏了各位的帮忙啊,总算是做出来一个简单的:
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 [D,f,s] = 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 [pl,ql,pr,qr] = 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)')
把这段代码复制粘贴到命令行,也能运行。照理说结果应该一样才对啊,可是实际上得出的曲线却完全不一样!高手给找一下看是什么原因、、 |