Advertisement
Guest User

Untitled

a guest
May 6th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.27 KB | None | 0 0
  1. function [T,x]=generate_and_solve(N,k,h,Te)
  2.  
  3. for i=1:N-1
  4.     a(i)=h+2*k*N^2;
  5. end
  6. D1=diag(a);
  7. D=D1(1:N-1,1:N-1);
  8.  
  9. for i=1:N-1
  10.     b(i)=-k*N^2;
  11. end
  12. L1=diag(b,-1);
  13. L=L1(1:N-1,1:N-1);
  14.  
  15. for i=1:N-1
  16.     b(i)=-k*N^2;
  17. end
  18. U1=diag(b,1);
  19. U=U1(1:N-1,1:N-1);
  20.  
  21. A=D+L+U;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement