www.pudn.com > cedu_proximate.rar > cedu_proximate.m, change:2006-12-19,size:1823b

```clear
close all
n=length(x1);
x_h=(x1-min(x1))/max(x1-min(x1));
y_h=(y1-min(y1))/max(y1-min(y1));
x_h1=y_h;
y_h1=x_h;
N=0:n-1;
Fs=50;
t=N/Fs;
subplot(211);
plot(t,x_h,'r',t,y_h,'b');title('信号序列时间：xijing_xinpu_11083054');
xlabel('相对时间/秒');
%测度贴近度
sum_c=0;
sum_cc=0;
for i=1:n
if(x_h(i)<y_h(i)) xy_c(i)=x_h(i);
else             xy_c(i)=y_h(i);
end
sum_c=sum_c+xy_c(i);
sum_cc=sum_cc+x_h(i)+y_h(i);
end
N_c=2*sum_c/sum_cc

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
N_max1=0;
N_max2=0;
for j=1:2:10240
sumc1(j)=0;
sumc2(j)=0;
sumcc1(j)=0;
sumcc2(j)=0;
for i=(1+j):n
if(x_h(i-j)<y_h(i))   xy_c1(i)=x_h(i-j);
else                xy_c1(i)=y_h(i);
end
sumc1(j)=sumc1(j)+xy_c1(i);
sumcc1(j)=sumcc1(j)+x_h(i-j)+y_h(i);
if(x_h1(i-j)<y_h1(i))   xy_c2(i)=x_h1(i-j);
else                  xy_c2(i)=y_h1(i);
end
sumc2(j)=sumc2(j)+xy_c2(i);
sumcc2(j)=sumcc2(j)+x_h1(i)+y_h1(i);
end
N_h1(j)=2*sumc1(j)/sumcc1(j);
N_h2(j)=2*sumc2(j)/sumcc2(j);
if(N_h1(j)>N_max1)
N_max1=N_h1(j);
count1=j;
end
if(N_h2(j)>N_max2)
N_max2=N_h2(j);
count2=j;
end
end
Nh1=max(N_h1);
Nh2=max(N_h2);
subplot(212)
if(Nh2>Nh1)
count=count2
Nh=Nh2
time=count/50;
dl=time*1810/1000
N1=n-count;
t1=1:N1;
plot(t1/Fs,x_h(count:n-1),'r',t1/Fs,y_h(1:n-count),'b');title('基于相对时间偏差的最大相似度');
xlabel('相对时间/秒');
else
count=count1
Nh=Nh1
time=count/50;
dl=time*1810/1000
N1=n-count;
t1=1:N1;
plot(t1/Fs,x_h1(1:n-count),'r',t1/Fs,y_h1(count:n-1),'b');title('基于相对时间偏差的最大相似度');
xlabel('相对时间/秒');
end```