📄 comparepw.m
字号:
function genuine = comparepw(co1,co2)
% compare two signals and output similarity score using DTW
%
% dynamic programming algorithms taken from:
% http://www.ee.columbia.edu/~dpwe
% freeware copyright of Dan Ellis, of Electrical Engineering Department at
% Columbia University (fragment of original shown in == borders).
%
[co1r,co1c] = size(co1);
[co2r,co2c] = size(co2);
% pad smaller one if signals not same size
if (co1r > co2r)
pads = zeros((co1r-co2r),12);
co2 = vertcat(co2,pads);
end;
if (co2r > co1r)
pads = zeros((co2r-co1r),12);
co1 = vertcat(co1,pads);
end;
% ==========================================
%
% Construct the 'local match' scores matrix as the cosine distance
% between the signals
SM = simmx(abs(co1),abs(co2));
% Use dynamic programming to find the lowest-cost path between the
% opposite corners of the cost matrix
% Note that we use 1-SM because dp will find the *lowest* total cost
[p,q,C] = dp(1-SM);
% Bottom right corner of C gives cost of minimum-cost alignment of the two
genuine = C(size(C,1),size(C,2));
% ==========================================
%
return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -