Create a random 4X4 matrix >>A=rand(4) % the numbers are not going to agree with the ones here. type >>help rand A = 0.2760 0.1190 0.5853 0.5060 0.6797 0.4984 0.2238 0.6991 0.6551 0.9597 0.7513 0.8909 0.1626 0.3404 0.2551 0.9593 create a 4X1 vector: >>x = rand(4,1) x = 0.5472 0.1386 0.1493 0.2575 create a linear combination of columns of A call this b: >>b = A*x b = 0.3852 0.6545 0.8331 0.4213 check sizes of arrays/vectors: >>size(A) ans = 4 4 >>size(b) ans = 4 1 >>size(x) ans = 4 1 form an augmented matrix: >>A_augmented=[A,b] A_augmented = 0.2760 0.1190 0.5853 0.5060 0.3852 0.6797 0.4984 0.2238 0.6991 0.6545 0.6551 0.9597 0.7513 0.8909 0.8331 0.1626 0.3404 0.2551 0.9593 0.4213 >>size(A_augmented) ans = 4 5 type >>help rref use the rref command to find reduced echelon form. >>row_echelon=rref(A_augmented) row_echelon = 1.0000 0 0 0 0.5472 0 1.0000 0 0 0.1386 0 0 1.0000 0 0.1493 0 0 0 1.0000 0.2575 let x_re be the last column of the row echelon. It should agree with x: >>x_re = row_echelon(:,5) x_re = 0.5472 0.1386 0.1493 0.2575 type: >>help norm check how close x_re is from x: >>norm(x_re-x) ans = 5.9140e-16 check the linear independence of the columns of A: >>rref(A) ans = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 create a vector that's a linear combination of columns of A: >>b4=A(:,4)+2*A(:,1) b4 = 1.0580 2.0585 2.2011 1.2845 form a new matrix B: >>B=[A,b4] B = 0.2760 0.1190 0.5853 0.5060 1.0580 0.6797 0.4984 0.2238 0.6991 2.0585 0.6551 0.9597 0.7513 0.8909 2.2011 0.1626 0.3404 0.2551 0.9593 1.2845 check to see that indeed the last column reflects the structure of b4 as being the 4th column of A + 2*1st column of A: >>rref(B) ans = 1.0000 0 0 0 2.0000 0 1.0000 0 0 -0.0000 0 0 1.0000 0 -0.0000 0 0 0 1.0000 1.0000 --------------------------------------------- create a 3X2 matrix: >>A=rand(3,2) A = 0.8407 0.2435 0.2543 0.9293 0.8143 0.3500 replace the 2nd column by 56X the first column. the columns are no longer linearly independent. >>A(:,2)=56*A(:,1) A = 0.8407 47.0802 0.2543 14.2398 0.8143 45.6000 use rref to show the new A does not have linearly independent columns: >>rref(A) ans = 1 56 0 0 0 0