📄 cossimilarity.m
字号:
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)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -