daily pastebin goal
38%
SHARE
TWEET

Untitled

a guest Jan 21st, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. K = K(2:end-1,2:end-1);
  2. M = M(2:end-1,2:end-1);
  3. L=L(2:end-1,1);
  4.  
  5. %animation
  6. vidObj=VideoWriter('heat1D.avi');
  7. open(vidObj);
  8.  
  9. U0(1:N+1,1) = 0;
  10. U0 = U0(2:end-1);
  11. Q = 400;
  12. dt = 1e-3;
  13. figure;
  14.  
  15. for p=1:Q
  16.  
  17.   U1 = (M+dt*K)\(M*U0 + dt*L);
  18.   U0 = U1;
  19.  
  20.   plot(x, [0, U1; 0], 'b-o');
  21.   ylim([0 0 1]);
  22.   str = ['dt = ' num2str(dt) ', time = ' num2str(p*dt);
  23.   title(str);
  24.   currFrame = getframe(gcf);
  25.   writeVideo(vidObj, currFrame);
  26.  
  27. end
  28.  
  29. close(vidObj);
  30.  
  31. implay('heat1D.avi');
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top