getsquareddist.m

来自「Continuous Profile Models (CPM) Matlab T」· M 代码 · 共 38 行

M
38
字号
%% function d=getSquaredDist(t,r)%%%% distance function used with DTW function such as dp.m dp2.m and dpJenn.m%%%% assumes that t and r have dimension: [length x numDims]%% the squared distance is the sum of the squared differences across%% all dimensions at one time pointfunction x=getSquaredDist(t,r)%% CHANGES BY JENN:[N D]=size(t); [M D]=size(r);x=zeros(N,M);%% accumulate over each dimensionfor d=1:D    x = x + (repmat(t(:,d),1,M)-repmat(r(:,d)',N,1)).^2;endx=x/D;return%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% original code that I got from web[rows,N]=size(t); [rows,M]=size(r);%for n=1:N%    for m=1:M%        d(n,m)=(t(n)-r(m))^2;%    end%end%this replaces the nested for loops from above Thanks Georg Schmitz d=(repmat(t(:),1,M)-repmat(r(:)',N,1)).^2;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?