Guest User

Untitled

a guest
Jan 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.83 KB | None | 0 0
  1. function myPDE
  2. m = 0;
  3. x = linspace(0,.1,1);
  4. t = linspace(0,.1,1);
  5.  
  6. sol = pdepe(0,@myPDEPDE,@myPDEIC,@myPDEBC,x,t);
  7. u = sol(:,:,1);
  8.  
  9. figure;
  10. surf(x,t,u);
  11. title('u(x,t)');
  12. xlabel('Distance x');
  13. ylabel('Time t');
  14. % -------------------------------------------------------------------------
  15. function [c,f,s] = myPDEPDE(x,t,u,DuDx);
  16. c = 1;
  17. f = DuDx;
  18. s = 0;
  19. % -------------------------------------------------------------------------
  20. function [u0] = myPDEIC(x)
  21. while true
  22. if x < .5
  23.     u0 = 2*x;
  24.     break
  25. end
  26.  
  27. if x == .5
  28.     u0 = 1;
  29.     break
  30. end
  31.  
  32. if x > .5
  33.     u0 = 2*(1-x);
  34. break
  35. end
  36. end
  37. % -------------------------------------------------------------------------
  38. function [pl,ql,pr,qr] = myPDEBC(xl,ul,xr,ur,t);
  39. pl = 0;
  40. ql = 0;
  41. pr = 0;
  42. qr = 0;
  43. % -------------------------------------------------------------------------
Add Comment
Please, Sign In to add comment