% CMSC 426 help help plus demo % Simple interpreted commands help ops 7+3 8-2 2^7 sqrt(17*3^2) x = 7; y = 8; x*y % Notice difference between: z = x*y; % and z % Making a vector x = [1 2 3 4] % or y = 1:4; % or y1 = [y,y] % Making a column vector z = [1; 2; 3; 4] % or z = x' % Indexing into vectors x(2) x(2,3) x(2:4) % Adding vectors x + 3:6 % Scaling vectors 7*x % Vector operations sum(x) max(x) x.^2 y = x/(sqrt(sum(x.^2))) % Inner products theta1 = pi/4; theta2 = pi/8; u = [cos(theta1); sin(theta1)] v = [cos(theta2); sin(theta2)] u'*v acos(ans) pi/8 % Matrices A = [1, 2, 3; 4, 5, 6] B = [1, 0, 1; 0, 1, 0] % Note [A,A] [B;[7, 6, 5]] A+B C = [7, 2; 3, 1] C*A A*C I = eye(2) C C*I D = [4, 0; 4, 5] A A' C C' det(C) C inv(C) inv(C)*C C*inv(C) % Indexing A A(2,1) A(2,1:2) A(2,:) % Geometric transformations Q = [0, 0, 1, 1; 0, 1, 0, 1]; figure plot(Q(1,:), Q(2,:), 'o', 'LineWidth', 6) R = [cos(pi/4), sin(pi/4); - sin(pi/4), cos(pi/4)]; R*R' Qr = R*Q plot(Qr(1,:), Qr(2,:), 'o', 'LineWidth', 6) T = rand(2,2) [r1, s, r2] = svd(T) T r1*s*r2 r1*r1' s % Files pwd ls path help addpath % Look at function test test(3,4) % Images dog = imread('dog1.jpg'); figure image(dog); axis equal dogbw = rgb2gray(dog); figure imagesc(dogbw); colormap(gray) imagesc(imrotate(dogbw,45,'bilinear')); % iteration for i = 1:5 i, end