?? cossimilarity.m
字號(hào):
function cosine = cosSimilarity(mat1, mat2)
% cosSimilarity: Cosine of the angles betweeen two set of vectors
% Usage: cosine = cosSimilarity(mat1, mat2)
% Returns the cosine of the angles between two set of vectors mat1 and mat2.
% The element at row i and column j of the return matrix is the cosine of the angle between
% column i of mat1 and column j of mat2.
% Roger Jang, 19971227, 20080915.
if nargin<1, selfdemo; return; end
if nargin<2, mat2=mat1; end
leng1 = (sum((mat1).^2).^.5);
leng2 = (sum((mat2).^2).^.5);
cosine = (mat1.'*mat2)./(leng1.'*leng2);
% ====== Selfdemo
function selfdemo
mat1=rand(3);
mat2=rand(3);
cos=feval(mfilename, mat1, mat2)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -