>> c1s6 Exercise number (1-14)? 4 A = 0.3500 -0.3000 -0.3000 -0.2000 0 -0.1000 0.9000 -0.1500 -0.1000 0 -0.2500 -0.3500 0.8500 -0.3000 0 0 -0.2500 -0.4000 0.6000 0 >> A(:,1:4) ans = 0.3500 -0.3000 -0.3000 -0.2000 -0.1000 0.9000 -0.1500 -0.1000 -0.2500 -0.3500 0.8500 -0.3000 0 -0.2500 -0.4000 0.6000 >> % Taking the first four columns of A, and ignoring the last column of zeros >> % We can use the above command to remove the last column of A: >> A=A(:,1:4) A = 0.3500 -0.3000 -0.3000 -0.2000 -0.1000 0.9000 -0.1500 -0.1000 -0.2500 -0.3500 0.8500 -0.3000 0 -0.2500 -0.4000 0.6000 >> A=-A A = -0.3500 0.3000 0.3000 0.2000 0.1000 -0.9000 0.1500 0.1000 0.2500 0.3500 -0.8500 0.3000 0 0.2500 0.4000 -0.6000 >> % just change the sign of every entry in A; Now we get the coefficient matrix in the Lecture notes >> Arref = rref(A) Arref = 1.0000 0 0 -2.0279 0 1.0000 0 -0.5311 0 0 1.0000 -1.1681 0 0 0 0 >> % Let us get p_A as the free variable - we need to have the column >> % for p_A sitting last, i.e., 4th in the A matrix >> A(:,[2 3 4 1]) ans = 0.3000 0.3000 0.2000 -0.3500 -0.9000 0.1500 0.1000 0.1000 0.3500 -0.8500 0.3000 0.2500 0.2500 0.4000 -0.6000 0 >> A A = -0.3500 0.3000 0.3000 0.2000 0.1000 -0.9000 0.1500 0.1000 0.2500 0.3500 -0.8500 0.3000 0 0.2500 0.4000 -0.6000 >> B=A(:,[2 3 4 1]) B = 0.3000 0.3000 0.2000 -0.3500 -0.9000 0.1500 0.1000 0.1000 0.3500 -0.8500 0.3000 0.2500 0.2500 0.4000 -0.6000 0 >> Brref = rref(B) Brref = 1.0000 0 0 -0.2619 0 1.0000 0 -0.5760 0 0 1.0000 -0.4931 0 0 0 0 >> Arref Arref = 1.0000 0 0 -2.0279 0 1.0000 0 -0.5311 0 0 1.0000 -1.1681 0 0 0 0 >> 1/2.03 ans = 0.4926 >> 1/2.0279 ans = 0.4931 >> 0.53/2.03 ans = 0.2611 >> % Can do a row swap ERO more directly using this method >> B B = 0.3000 0.3000 0.2000 -0.3500 -0.9000 0.1500 0.1000 0.1000 0.3500 -0.8500 0.3000 0.2500 0.2500 0.4000 -0.6000 0 >> % ERO - swap R1 and R4 in B >> B([4 2 3 1],:) ans = 0.2500 0.4000 -0.6000 0 -0.9000 0.1500 0.1000 0.1000 0.3500 -0.8500 0.3000 0.2500 0.3000 0.3000 0.2000 -0.3500 >> B=B([4 2 3 1],:) B = 0.2500 0.4000 -0.6000 0 -0.9000 0.1500 0.1000 0.1000 0.3500 -0.8500 0.3000 0.2500 0.3000 0.3000 0.2000 -0.3500 >> % saying 'help CMD' will print the help for any command CMD >> help rref