Advertisement
UF6

Homework I, Problem I

UF6
Oct 25th, 2020
2,395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.73 KB | None | 0 0
  1.  
  2. %This is posted and ran in a separate file before running the code below.
  3. A=[-2,1,0,0,0,0,0,0;1,-2,1,0,0,0,0,0;0,1,-2,1,0,0,0,0;0,0,1,-2,1,0,0,0;0,0,0,1,-2,1,0,0;0,0,0,0,1,-2,1,0;0,0,0,0,0,1,-2,1;0,0,0,0,0,0,1,-2];
  4.  
  5. %Again, this is posted in a separate file named 'triang'.
  6. %The issue I am having is the error in live five reads: "Not enough input arguments.Error in triang (line 5)[m,n]=size(A);"
  7.  
  8. function B= triang(A)
  9. %%%Input A--> Matrix for m*n for the size
  10. %%%Output B--> Is the upper triangular matrix of the same size
  11. [m,n]=size(A); %This is the line I am having issues with.
  12. for k=1:m-1
  13.     for i=k+1:m
  14.         u=A(i,k)/A(k,k);
  15.         for j=(k):n
  16.             A(i,j)=A(i,j)-u*A(k,j);
  17.         end
  18.     end
  19. end
  20. B = A;
  21. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement