source:
proiecte/PPPP/ica/cosFn.m
Last change on this file was 94, checked in by , 14 years ago | |
---|---|
File size: 423 bytes |
Line | |
---|---|
1 | % function [S] = cosFn(mat1,mat2), |
2 | % Computes the cosine (normalized dot product) between training vectors in |
3 | % columns of mat1 and test vectors in columns of mat2. Outputs a matrix of |
4 | % cosines (similarity matrix). |
5 | % |
6 | % Written by Ian Fasel. |
7 | |
8 | function [S] = cosFn(mat1,mat2), |
9 | |
10 | denom = sum(mat1.^2,1)*sum(mat2'.^2,2); |
11 | denom (find(denom==0)) = 0.00000000000000000000001; |
12 | numer = mat1'*mat2; |
13 | |
14 | S = numer./denom; |
Note: See TracBrowser
for help on using the repository browser.