本文根据matlab 帮助进行加工,根据matlab 帮助上的例子,帮助更好的理解一维偏微分方程的pdepe 函数解法,主要加工在于程序的注释上
Ex amples Ex ample 1
This example illustrates the straightforward formulation, computation, and plotting of the solution of a single PDE
This equation holds on an interval for times
The PDE satisfies the initial condition and boundary conditions It is convenient to use subfunctions to place all the functions required by pdepe in a single function
function pdex1 m = 0; x = linspace(0,1,20); %linspace(x1,x2,N)linspace是Matlab中的一个指令,用于产生x1,x2之间的N点行矢量
%其中x1、x2、N分别为起始值、终止值、元素个数
若缺省N,默认点数为100 t = linspace(0,2,5); sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t); % Extract the first solution component as u
u = sol(:,:,1); % A surface plot is often a good way to study a solution
surf(x,t,u) title('Numerical solutio