Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %%Intro
- %Setup constants
- clear all
- clc
- MatrixRows = 15;
- MatrixCols = 15;
- %Setup random number generator
- rand('state', sum(clock*100));
- %Generate matrix A and vector b
- A = vpa(rand(MatrixRows,MatrixCols));
- b = vpa(rand(MatrixRows,1));
- %%Body
- %Solve Ax = b by x = A\b
- x = A\b
- %Solve Ax = b by U = rref([A b])
- U = rref([A b]);
- y = U(:,MatrixCols+1)
- R = b - A * x
- S = b - A * y
- %%Conclusion
- %Matlab reports that both x = y, and that R = S, within floating point
- %precision
Add Comment
Please, Sign In to add comment