graphing my first PDE

5 views (last 30 days)
Rushan
Rushan on 19 Sep 2014
Answered: Rushan on 19 Sep 2014
Hello! I am new to Matlab and trying to graph my first PDE. I have no idea how it works, can any one help me with how to write the script for the following PDE
c(∂u∂x) + ∂u∂t = 0 with initial condition u(x, 0) = arctan(x). Plot the solution to this PDE for a few different values of c (small, large, positive, negative)
Thanks :)

Accepted Answer

Rushan
Rushan on 19 Sep 2014
how do find the correct boundary conditions when (initial condition) uo = atan(x) and the PDE equation is c(∂u∂x) + ∂u∂t = 0 ?

More Answers (1)

David Sanchez
David Sanchez on 19 Sep 2014
take a look at the documentation.
doc pdepe
will present a very good example. This same example is explained in more detail in the following link:
You can easily adapt that example to solve your problem
  1 Comment
Rushan
Rushan on 19 Sep 2014
thanks for the link. I tried writing the script for the equation, but i'm getting an error :(
PDE equation: c(∂u∂x) + ∂u∂t = 0
PDE equation in MATLAB format: 1/-c (DuDt) = x^-0 (x^0 DuDx) + 0 (not sure if its correct)
Here is my script: ---------------------------------------------------------------------------
function [c,f,s] = pdex1pde(x,t,u,DuDx)
c = -1;
f = DuDx;
s = 0;
function u0 = pdex1ic(x)
u0 = arctan(x);
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)
pl = ul;
ql = 0;
pr = 5;
qr = 1;
m = 0;
x = linspace(0,1,20);
t = linspace(0,2,5);
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);
u = sol(:,:,1);
surf(x,t,u)
title('Numerical solution computed with 20 mesh points')
xlabel('Distance x')
ylabel('Time t')
---------------------------------------------------------------------------
Please Help me out !!! :(

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!