Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function myPDE
- m = 0;
- x = linspace(0,.1,1);
- t = linspace(0,.1,1);
- sol = pdepe(0,@myPDEPDE,@myPDEIC,@myPDEBC,x,t);
- u = sol(:,:,1);
- figure;
- surf(x,t,u);
- title('u(x,t)');
- xlabel('Distance x');
- ylabel('Time t');
- % -------------------------------------------------------------------------
- function [c,f,s] = myPDEPDE(x,t,u,DuDx);
- c = 1;
- f = DuDx;
- s = 0;
- % -------------------------------------------------------------------------
- function [u0] = myPDEIC(x)
- while true
- if x < .5
- u0 = 2*x;
- break
- end
- if x == .5
- u0 = 1;
- break
- end
- if x > .5
- u0 = 2*(1-x);
- break
- end
- end
- % -------------------------------------------------------------------------
- function [pl,ql,pr,qr] = myPDEBC(xl,ul,xr,ur,t);
- pl = 0;
- ql = 0;
- pr = 0;
- qr = 0;
- % -------------------------------------------------------------------------
Add Comment
Please, Sign In to add comment