我需要解决球形pde扩散方程:
DQ / DT =(1 / R ^ 2)* d / DR(R ^ 2 * d *(DQ / DR))
D是常数
初始条件是t = 0时的q = 0
边界条件为:r = 0时dq / dr = 0,r = Rc时q = 1
我写了以下代码,但收到错误:
function pde1
m=2;
x=linspace(0.01,1,20);
t=linspace(0.01,2,10);
sol=pdepe(m,@pdefun,@pdeic,@pdebc,x,t);
u=sol(:,:,1);
% A surface plot
surf(x,t,u)
title('Surface plot')
xlabel('Distance x')
ylabel('Time t')
end
%-----------------------------------
function [c,f,s]=pdefun(x,t,u,DuDx)
global d
c=1/d;
f=DuDx;
s=0;
end
%-----------------------------------------------------
function [pl,ql,pr,qr]= pdebc(xl,ul,xr,ur,t)
global r
pl=0;
ql=0;
pr=1;
qr=r;
end
%------------------------------------------------
function u0 = pdeic(x)
u0=0;
end
你可以告诉我它有什么问题吗?
错误是:
Error using /
Matrix dimensions must agree.
Error in pdefun (line 3)
c=1/d;
Error in pdepe (line 246)
[c,f,s] = feval(pde,xi(1),t(1),U,Ux,varargin{:});
Error in pde1 (line 5)
sol=pdepe(m,@pdefun,@pdeic,@pdebc,x,t);
由于