%Create the matrix A from class
A=[3 2 3; 1 -1 -4]
% A row vector x
x=[2 3 7]
% Redefine x as its (conjugate)transpose x' (which will make x a column
% vector
x=x'
% Alternative way of creating a column vector
x=[2; 3; 7]
% Multiply x with A
y=A*x
% Want to learn how the command rref works (which will transform a matrix
% to its reduced row echelon form
help rref
% Define the (column) vector b
b=[0;1]
% and the augmented matrix [A | b]
Aaug=[A b]
% Bring Aaug into its reduced row echelon form
rref(Aaug)
% Create 3x3 and 5x5 identity matrices
eye(3)
eye(5)
% Create a random 3x3 matrix A (entries random integers between 1 and 5
A=randi(5,3,3)
% Compute the inverse of A
inv(A)
% Now compute the inverse of A using Gaussian elimination (rref)
rref([A eye(3)])
% Pick some vector b
b=[1;1;2]
% Solve Ax=b in two different ways
x=inv(A)*b
x=A\b
%Compare which method is faster
tic;inv(A)*b; toc
tic;A\b; toc
%Try it with much larger matrices
A = rand(1000, 1000);
b = rand(1000, 1);
%Compare which method is faster
tic;inv(A)*b; toc
tic;A\b; toc