function[c,f,s] = pde_description(x,t,u,dudx)% pde_description outputs the descrition of the partial differential
% equation to be solved in terms of the variables c,f and s given the
% input variables x,t,u and dudx
%
% Version no:1 Date of Creation: 03/05/2018 09:29 Author: Naomi Akinyede
c = 1;f = 2*x + dudx;s = 0;end function u0 = pde_initial_cond(x)% pde_initial_cond outputs the initial conditions of pde_description given
% the in the input variable x
%% Version no:1 Date of Creation: 03/05/2018 09:29 Author: Naomi Akinyedeu0 = x^2 - 0.5;endfunction [pl,ql,pr,qr] = pde_boundary_cond(xl,ul,xr,ur,t)% pde_boundary cond outputs the boundary conditions of pde_descrition given
% the xl,xr,ul and ur corresponding to the left and right boundary
% conditions and t corresponding to some time vector
%% Version no:1 Date of Creation: 03/05/2018 09:29 Author: Naomi Akinyedepl = ul - 0.5;ql = 0;pr = ur - 3.5;qr = 0;endxx = linspace(-1,2,10);tt = linspace(0,0.015,15);sol = pdepe(0,@pde_description,@pde_initial_cond,@pde_boundary_cond,xx,tt);
MATLAB: Hi, is this the right code for the pde (∂u/∂t= 2 + (∂^2 u)/(∂x^2 )) with boundary conditions of 0.5 and 3.5 and initial condition of x^2 – 0.5 where x ranges from -1 to 2
pdepe
Best Answer