hlsdk

hlsdk

Feb 16th, 2010
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. %%Intro
  2. %Setup constants and formatting
  3. clear all
  4. clc
  5. digits(5);
  6.  
  7. MatrixRows = 5;
  8. MatrixCols = 7;
  9. VectorSize = 7;
  10.  
  11. %Setup random number generator
  12. rand('state', sum(clock*100));
  13.  
  14. %Generate matrix A and vector u
  15. A = vpa(rand(MatrixRows,MatrixCols));
  16. u = vpa(rand(VectorSize,1));
  17.  
  18. %%Body
  19. %Put matrix A into REF
  20. A = rref(A)
  21.  
  22. %Calculate the product b = Au
  23. b = A*u
  24.  
  25. %Solve for x by setting x = A\b
  26. x = A\b
  27.  
  28. %Show augmented matrix produced by Ax = b or Au = b
  29. U = rref([A b])
  30.  
  31. %%Conclusion
  32. %Computing b as the product of A and u, we were able to solve for u by
  33. %divinding A by b.
  34.  
  35. %Matlab shows b == x only when digits() or vpa() are on.
  36.  
  37. %There are infinitely many solutions because A has 2 free variables,
  38. %corresponding to the last 2 columns.
Add Comment
Please, Sign In to add comment