What's a nice simple PDE to play with in Matlab?

I want to learn a very simple PDE to gain physical and mathematical intuition—a PDE with just one spatial dimension $$x$$ and a time dimension $$t$$. And, I want to write code for it in Matlab and use a standard PDE solver that Matlab might have, so that I can get a feel for the solution to the PDE and how the solution changes/behaves with a change in $$x$$ or $$t$$.

• I have no experience with PDEs.

• What's a nice Matlab solver for PDEs?

• For ODEs, the Matlab solver ode45 is pretty nice to use.

• A really basic one that fits your desired criteria could be the unsteady heat equation in 1D. As for PDE solvers in matlab, never used one so I can’t comment. I have always rolled my own PDE solving code if I write something in matlab. – spektr Jan 8 '20 at 7:07
• @spektr interesting: is there a standard solver code that I could learn to write on my own? do you have a reference maybe? I'd also like to write a simple solver, so that I can understand the numerical method underlying the solver. – user33775 Jan 8 '20 at 7:11
• Well a common approach is to discretize the spatial derivatives of the PDE to obtain a system of ODEs and then solve this system with ‘ode45’ or something along these lines. The easiest discretization is to turn spatial derivatives into finite difference approximations. – spektr Jan 8 '20 at 7:17
• @spektr how long does it take to learn this, in your estimation? maybe a week for the unsteady heat equation? how many lines of matlab code would it be? less than 100 lines of code maybe? (sorry for my cluelessness.) – user33775 Jan 8 '20 at 8:37

Standard examples of PDE to solve with the typically taught basic discretization methods (Crank-Nicolson et al.) are

• Transport equations, and other first order equations like Burger's, have often explicit solutions and conservation laws that the numerical methods more-or-less satisfy

• The heat equation with different boundary conditions and source terms is the teaching example for Crank-Nicolson and related methods,

• The KdV, Korteweg-deVries equation with a soliton wave (animating a wave function in MATLAB) or multiples of them, (Zabusky and Kruskal's stepper for the KdV equation) is heavily non-linear and teaches why stiffness has to be taken into account, thus the use of implicit solver methods.

• In using complex-valued functions, one can explore the non-linear Schrödinger (NLS) equations (pseudo-spectral method in NLS), with the same difficulties as the last one.

If you're interested in modelling any type of PDE within MATLAB, the Partial Differential Equation Toolbox should be able to handle anything you're interested in.

This includes tools for meshing, solving and visualising the results from a user defined system of equations. It can handle both time and spatially dependent systems simultaneously.

The complete documentation holds a significant volume of worked examples which would probably be helpful in gaining some intuition for various systems. PDEPE make also be a useful function for 1D problems.