MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [求助]如何取一段高频信号的包络啊 (https://www.labfans.com/bbs/showthread.php?t=5838)

xiangrufeia 2008-12-14 20:05

[求助]如何取一段高频信号的包络啊
 
function smf = matchedfilter(s,r,fs)

% MATCHEDFILTER calculates the matched filter output
% of signal s with replica r.
%
% smf = matchedfilter(s,r,fs)
%
% input:
% s : the signal
% r : the replica
% fs : the sample frequency
% output:
% smf : the matchedfilter output


ls = size(s);
if (ls(1) ~= 1),
s = s';
end
ls = max(ls);

r(r==0) = [];
lr = size(r);
if (lr(1) ~= 1),
r = r';
end
lr = max(lr);
T = lr/fs;

if (ls < lr),
error('Replica must have smaller length than signal');
end

% Normalize replica on energy 1
%r = r/sqrt(r*r');

% Normalize replica on maximum amplitude 1
r = r/abs(max(r));

% determine number of points in fft
p = 2^ceil(log(ls)/log(2));
if p==ls, % remove wrap around effects when
p=2*p; % signal is already 2^n in length
end

% correlation by multiplication in frequency domain
y = conj(fft(r,p)).*fft(s,p);

% perform Hilbert transform (stolen from hilbert.m)
% throw away negative frequencies and double positive frequencies
if p ~= 1
% freq>0 Nyquest freq<0
h = [1; 2*ones(fix((p-1)/2),1); ones(1-rem(p,2),1); zeros(fix((p-1)/2),1)];
y(:) = y(:).*h;
end

% matched filtered output
[COLOR="Red"]smf = abs(ifft(y))'; % envelope[/COLOR][COLOR="red"]这个应该是取包络的意思,可是我不太明白,请高手指教啊[/COLOR]%smf1 = real(ifft(y)'); % real part
%smf2 = imag(ifft(y)'); % imaginery part

smf(ls+1:p) = []; % adjust the output to same length as input signal
smf = smf*2/T/fs; % normalization according to amplitude signal

%figure;
%plot(smf);

% end


所有时间均为北京时间。现在的时间是 12:28

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.