% --------------------------------------------- % Example matrix from Mike Berry's baby example % --------------------------------------------- A = [... 0 1 0 1 1 0 1 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 1 0 0 1 0 0 0 ]; [m,n] = size(A); % --------------------------------------------- % Normalize the columns of A. Can this be done % without using a loop? % --------------------------------------------- for k = 1:n A(:,k) = A(:,k)/norm(A(:,k)); end % Query vector corresponding to "Baby Proofing" q1 = [0 1 0 0 0 0 1 0 0]'; q1 = q1/norm(q1); % The set of all cosines corresponding to query A'*q1