写在前面:仅作为个人学习笔记,便于以后查阅,如对你有帮助,荣幸之至,如有错误,欢迎评论指正
编程软件:matlab R2018b
系统: win10
系列文章目录
- chirp信号的生成与接收
- 对接收到的chirp信号进行滤波、分帧处理及端点检测
- 计算原始chirp信号与滤波后chirp信号的相关性
- 绘制接滤波后chirp信号的时域图和频域图
- 从1-4完整走一遍
文章目录
- 系列文章目录
- 相关性计算
- 参考文献
相关性计算
本案例计算发射的信号与接收到的回声的相关性,以此判断回声信号的哪些部分包含了我们的发射信号,换言之,我们采集的回声信号里除了环境杂音,还有我们自己发出的声音信号。
相关性计算的具体代码如下corr_compute.m
:
function corrSeq = corr_compute(data1, sampleSignal) %%%data initilization
sizeOfSample = length(sampleSignal);
sizeOfData = length(data1);
output = zeros(sizeOfData, 1); %%%Compute the correlation
for i = 1 :1 : sizeOfData-sizeOfSampleoutput(i,1) = abs(dot(sampleSignal', data1(i:i+sizeOfSample-1, 1)));
end%%%Return the final values
corrSeq = output; % figure
% t1 = 1:length( output );
% %t2 = t1/samplingRate;
% plot(t1, output,'LineWidth',2,'Color','b');
% hold on;%%%Conduct the envelop detection
window_size_for_envelope = 30; %%%The length of each frame%%%Count the number of windows we need
counter=0;
for i=1:(window_size_for_envelope - 1) : (length(corrSeq) - window_size_for_envelope)counter=counter+1;
end
envelope_m=zeros(counter,1);%%%COmpute the values for each frame
counter=1;
for i=1:( window_size_for_envelope - 1 ) : (length(corrSeq) - window_size_for_envelope)current_window = corrSeq(i:i+window_size_for_envelope-1,:);min_value=min(current_window);max_value=max(current_window);envelope_m(counter,1) = max_value; %%upper part% envelope_m(counter,1) = min_value; %%lower partcounter=counter+1;
end%%%Conduct the interpolation
x=1:( window_size_for_envelope - 1 ):(length(corrSeq) - window_size_for_envelope); %%%The position of the sampled points
y=envelope_m; %%%The value of sampled points
x_i=1:(length(corrSeq) - window_size_for_envelope); %%%The vector size after interpolationy_i = interp1(x,y,x_i,'spline');%%%Return the results
corrSeq = y_i;
发射的信号与接收到的回声的相关性如下图所示,纵轴代表归一化后的相关性强度,横轴代表样本点序列,纵轴值越大,两个信号的相关性越高。可以设置一个阈值a,当相关性的值超过阈值a时,可认为该时段的声音信号为回声信号。
参考文献
- 宋知用.MATLAB语音信号分析与合成(第2版)[M].北京:北京航空航天大学出版社,2017.10.