% % ex1.m is an example matlab program % % ----- save output to file ----- % clear all diary ex1.mout diary off delete ex1.mout diary ex1.mout % ----- display date and time of computation ----- % format short date time0 = clock; % ----- enter matrices ----- % a = [5; 4; 2]; b = [1; 1; 2]; AA = [2 1 3; 1 3 2; 3 2 5]; % - to print matrices just list them - % a, b, AA a b AA % ----- create special matrices in matlabl ----- % iota = ones(10,1); ident = eye(10); iota, ident % ----- use of the addtion, multiplication, and transpose operators ----- % temp = a'+b'; temp1 = (a+b)'; temp, temp1 temp = a'*AA; temp1 = AA*AA; temp2 = AA^2; temp, temp1, temp2 % ----- enter data into matrices ----- % y = [89.2121; 89.8565; 90.4337; 89.6069; 90.8523; 89.1211; 90.7312; 89.9642; 90.1163; 88.8782]; x = [1 11; 1 13; 1 22; 1 12; 1 24; 1 10; 1 9; 1 8; 1 17; 1 22 ]; % ----- compute eigenvalues/vectors ---- % P = [.9 .1 ; .3 .7]; pie = [.5 ; .5]; y = [1 ; 5] L2a = pie(1,1)*P(1,2)*P(2,1)*P(1,2)*P(2,1) P2d = pie'*y P2e = P*y P2e = P^2*y P2e = P^3*y F2g = inv( eye(2) - 0.9*P) * y % - note V is eigenvectors - % [V,D] = eig(P'); V, D test = V(:,1) test1 = V(1,:) test2 = V(1,1:2) test3 = V(1,1:1) % ----- compute some traces ----- % trace(P) trace(P') trace(P*P') trace(P'*P) % ----- turn off diary ----- % comptime = etime(clock, time0) diary off