>> i=2; >> if i==3 disp('Hi!'); % this works if i is 3 else disp('Ho!'); % this works if i is NOT 3 end Ho! % since i was 2 to start with, the second option was implemented >> while i <= 5 i = i+1 % as long as i is less that or equal to 5, increment i by 1 in each step end i = 3 i = 4 i = 5 i = 6 >> if i~=5 % not equal to is tested using ~= disp('ho ho!') end ho ho! % notice that i was set to 6 at the end of the previous while loop. >> >> A = [0 5 2 4;0 0 0 0; 2 3 0 2]; >> [A1,ne] = MyRREF(A) % MyRREF written by Bala A1 = 1.0000 0 -0.6000 -0.2000 0 1.0000 0.4000 0.8000 0 0 0 0 ne = 5 >> A2 = rref(A) A2 = 1.0000 0 -0.6000 -0.2000 0 1.0000 0.4000 0.8000 0 0 0 0 >> norm(A1-A2) ans = 2.0015e-16 % this number is essentially zero >> m=8;n=10;A= round(m*rand(m,n)) A = 7 8 3 5 2 4 6 8 7 7 7 8 7 6 0 3 6 3 8 2 1 1 6 6 1 6 2 5 4 7 7 8 8 3 7 6 5 2 1 3 5 8 5 5 6 1 5 6 1 2 1 4 0 1 3 4 1 2 2 2 2 6 7 6 8 4 1 4 7 5 4 1 7 0 0 5 4 6 2 4 >> [A1,ne] = MyRREF(A) A1 = Columns 1 through 8 1.0000 0 0 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 0 1.0000 Columns 9 through 10 1.6131 1.5802 1.6700 -0.7755 0.6750 -0.4112 0.2107 0.7488 -1.5352 0.1666 0.1191 0.5898 -4.3192 -1.3583 0.9724 0.6362 ne = 63 >> A2 = rref(A) A2 = Columns 1 through 8 1.0000 0 0 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 0 1.0000 Columns 9 through 10 1.6130 1.5802 1.6700 -0.7755 0.6750 -0.4112 0.2107 0.7488 -1.5352 0.1666 0.1190 0.5898 -4.3191 -1.3583 0.9724 0.6362 >> norm(A1-A2) ans = 3.1273e-05 % again, this number is essentially zero