hlsdk

hlsdk

Feb 16th, 2010
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. %%Intro
  2. %Setup constants
  3. clear all
  4. clc
  5. MatrixRows = 15;
  6. MatrixCols = 15;
  7.  
  8. %Setup random number generator
  9. rand('state', sum(clock*100));
  10.  
  11. %Generate matrix A and vector b
  12. A = vpa(rand(MatrixRows,MatrixCols));
  13. b = vpa(rand(MatrixRows,1));
  14.  
  15. %%Body
  16. %Solve Ax = b by x = A\b
  17. x = A\b
  18.  
  19. %Solve Ax = b by U = rref([A b])
  20. U = rref([A b]);
  21. y = U(:,MatrixCols+1)
  22.  
  23. R = b - A * x
  24. S = b - A * y
  25.  
  26. %%Conclusion
  27. %Matlab reports that both x = y, and that R = S, within floating point
  28. %precision
Add Comment
Please, Sign In to add comment