Problem with a PDE harmonic oscillator.

2 visualizaciones (últimos 30 días)
Stephen
Stephen el 26 de Feb. de 2014
I am trying to get and graph numerical solutions to a PDE with an initial condition and two boundary conditions.
PDE: du/dt = -(h^2/4)*d^2u/dt^2+x^2*u
IC: u(x,0)=Exp[(a-b)(a-b)/(.32)]
BC: u(-10,t)=0 and u(10,t)=0
this is my attempt at coding.
function expde
m = 0;
x = linspace(0,1,5);
t = linspace(0,100,20);
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);
% Extract the first solution component as u.
u = sol(:,:,1);
surf(x,t,u)
title('Graph of Wave Function')
xlabel('Distance x')
ylabel('Time t')
% --------------------------------------------------------------
function [c,f,s] = pdex1pde(x,t,u,DuDx)
c = 1;
f = ((.1)^2/4)*DuDx;
s = x^2*u;
% --------------------------------------------------------------
function u0 = pdex1ic(x)
u0 = exp((x-.1)^2/.32);
% --------------------------------------------------------------
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)
pl = 0;
ql = -10;
pr = 0;
qr = 10;
it is pretty obviously not working. Can somebody explain what i am doing wrong? I would also like to plot u^2 instead of u but i don't know how. Any help would be greatly appreciated. I have working code in mathematica but i plan on expanding and editing a few terms that i will need matlab for. Thanks

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by