如图,分别为两个y1,y2信号,长度分别为88200,90000个采样点。
(1)取y1,y2(1,9000)的采样点,求1000个互相关值
(1)取y1,y2(1,81000)的采样点,求1000个互相关值
如图为y1,y2
%load('data20231018.mat');
%y1=a';
%y2=b';
n1=9000;
m1=1000;
figure(5);plot(1:2000:90000,y1(1:2000:90000)),grid on;
figure(6);plot(1:2000:90000,y2(1:2000:90000)),grid on;
% 第一种情况
data1=y1(1:n1);
data2=y2(1:n1);
data2=[data2 zeros(1,n1)];%长度不一要补零
corr1_my=zeros(1,n1);
for i=1:1000
corr1_my(i)=(sum(data1(1:n1).*data2(i+1:n1+i)))/n1;%计算互相关函数
end
figure(1);plot(corr1_my(1:1000),'.','color','r'),title('互相关函数 9000 piont'),grid on;
% 第二种情况
n2=81000;
m2=1000;
data3=y1(1:n2);
data4=y2(1:n2);
data4=[data4 zeros(1,n2)];
corr2_my=zeros(1,n2);
for i=1:1000
corr2_my(i)=(sum(data3(1:n2).*data4(i+1:n2+i)))/n2;
end
figure(2);plot(corr2_my(1:1000),'.','color','r'),title('互相关函数 81000 piont'),grid on;