马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
各位大虾帮帮忙。我又两序列信号,一个是发射信号,一个是接收信号,两信号假设被传感器检测到的时间相差D。我想用lms自适应的方法求两信号的时间差D。我模拟出了两信号,并且根据自适应原理编程实现,可结果总是不对,希望懂的给指导一下。下面是我的程序。大家看看哪儿出错了
第一个
%% the envelop of the simulation original signal and delay signal without
% noise;
% parameter:tau is the delay factor;
% used for solving the delay time;
% new program;
%% emission signal model
function twosignal(tau)
a=1.2*10.^4;f=40000;phi=0;
close all;
t=0:10.^(-6):3*10.^(-3);
alfa=a*t.^1.*exp(-t/(2*10^(-4)));
beta=cos(2*pi*f*t);
e_s=alfa.*beta;
y=hilbert(e_s); % 或者abs(sn)
e_ss=sqrt(real(y).^2+imag(y).^2);
e_ss=e_ss+0.05*randn(size(t));
subplot(211);plot(t,e_ss);title('Original Sigal');grid on
%% the receipt model
alfa=a*(t-tau).^1.*exp(-(t-tau)/(2*10^(-4))); % @
beta=0.*(t<tau)+cos(2*pi*f*(t-tau)+phi).*(t>=tau);% tau此处不能为0,分段函数作图方法
r_s=alfa.*beta;
y=hilbert(r_s); % 或者abs(sn)
r_ss=sqrt(real(y).^2+imag(y).^2);
r_ss=r_ss+0.05*randn(size(t));
hold on;plot(t,r_ss);title('Delay Sigal');
%% save
save time t;
save e_s e_ss; % the envelop of the original signal
save r_s r_ss; % the envelop of the return signal
%% command:twosignal(0.0003);
第二个程序
clear
close all;
load time; % load the time sequence
load e_s; % load the emission signal
load r_s; % load the receive signal
t;e_ss;r_ss;
e_signal=e_ss;
r_signal=r_ss;
subplot(311);plot(t,e_signal);grid on;
hold on;plot(t,r_signal);
title('Emission & Return signal');
%% begin of algorithm
% initialization
L=385; % 滤波器阶数
points=length(t); % the simple-points
d=r_ss(1:points)';
X=e_ss(1:points)';
y=zeros(1,points)'; % system output signal
w=zeros(L,1); % 每列代表每次迭代的L个权值,行代迭代次数,第几次
D=zeros(1,points);
a=0.001;b=10;
% LMS arithmetic
for n=L:points
e(n)=d(n)-w'*X(n:-1:n-L+1);
u=a*(1-exp(-b*(abs(e(n)).^2))); % 王小川的《基于》
w=w+u*e(n)*X(n:-1:n-L+1);
end
%for tt=1:points
% D(tt)=w(:,n)'*(sinc(t(tt)-(1:L)))'; % 参考王小川的《基于》interpolation
%end
subplot(312);plot(w);grid on;axis tight; % the approximate signal after the lms filter
[wm,m]=max(w);hold;plot(m,wm,'or');
%subplot(313);plot(t,D);grid on;axis tight; % the weighted value---filter coefficient
%[Dmax,c]=max(D); % find the maximum of the weighted value array
%tt=t(c); % look for the corresponding time spot of the maximum
%hold on;plot(tt,Dmax,'or') % draw the spot |