資源簡介
基于MATLAB的相關性聲波測距,利用產生回波,使用相關性算法計算回波距離
代碼片段和文件信息
%%單個回音%%
[xfsbits]?=?wavread(‘music11.wav‘);
t?=?(0:length(x)-1)/fs;
figure(1);
subplot(311);
plot(x);xlabel(‘采樣點‘);ylabel(‘幅度‘);
title(‘原信號‘);
y?=?fft(x);
subplot(312);plot(abs(y));title(‘原信號幅值‘);
subplot(313);plot(angle(y));title(‘原信號相位‘);
%sound(xfs);pause(5);
%回聲信號
x1?=?x;x2?=?x;
x1?=?[x1‘zeros(120000)];
x2?=?[zeros(112000)0.6*x2‘zeros(18000)];
y2?=?x1+x2;
y2_2?=?fft(y2);
figure(2);
subplot(311);plot(y2);title(‘回聲信號‘);
subplot(312);plot(abs(y2_2));title(‘回聲信號幅值‘);
subplot(313);plot(angle(y2_2));title(‘回聲信號相位‘);
%sound(y2fs);
%相關性測距
h?=?xcorr(y2);
figure(3);
subplot(211);plot(abs(h));title(‘相關函數‘);
%h1?=?h(250000:260000);
%[h11h11_location]?=?max(h1);
%h11_location?=?h11_location+250000;
%
- 上一篇:循環交織、解交織
- 下一篇:FFT方式計算天線方向圖
評論
共有 條評論