function [cm, cSq] = DiscreteFrechetDist(P,Q,dfcn)
plot(P)%绘制曲线P
plot(Q)%绘制曲线Q
sP = size(P);
sQ = size(Q);
% check validity of inputs
if sP(2)~=sQ(2)
error('Curves P and Q must be of the same dimension')
elseif sP(1)==0
cm = 0;
return;
end
% initialize CA to a matrix of -1s
CA = ones(sP(1),sQ(1)).*-1;
% distance function
if nargin==2
dfcn = @(u,v) sqrt(sum( (u-v).^2 )); % @表示定义匿名函数
end
% final coupling measure value
cm = c(sP(1),sQ(1));
% obtain coupling measure via backtracking procedure
if nargout==2
cSq = zeros(sQ(1)+sP(1)+1,2); % coupling sequence
CApad = [ones(1,sQ(1)+1)*inf; [ones(sP(1),1)*inf CA]]; % pad CA
Pi=sP(1)+1; Qi=sQ(1)