필터 지우기
필터 지우기

How to get the phase sift of the filtering?

조회 수: 15 (최근 30일)
Péter Gyarmati
Péter Gyarmati 2017년 8월 10일
댓글: Star Strider 2017년 8월 28일
If I filter the signal, using filter(), there is a phase shift, between the original and the filtered signal. If I use filtfilt() function, the delay is compensated.
How may I know the amount of phase shift the filter causes, if my signal is stochastic (not a sine wave), and not periodic? For example the speed of a moving object. So it is hard to tell the base frequency component of the signal.
%%Time specifications:
Fs = 100; % samples per second
dt = 1/Fs; % seconds per sample
StopTime = 1; % seconds
t = (0:dt:StopTime-dt)'; % seconds
%%Sine wave:
Fc = 1; % Hz
x = sin(2*pi*Fc*t);
% Plot the signal versus time:
xlabel('time (in seconds)');
title('Signal versus Time');
zoom xon;
%%Generate random noise
rng('default');
r = randn(100,1);
r = r / 50*max(r);
y = x + r;
numd = [0.1667 0.1667];
dend = [1.000 -0.6667];
filtered_y = filter(numd, dend, y);
filtfilt_y = filtfilt(numd, dend, y);
plot(t,[x,y,filtered_y,filtfilt_y]);
ylim([-1.3, 1.3])
legend('Original signal','Noisy signal','Filtered signal','No phase shift filtered signal')
grid on
  댓글 수: 2
KALYAN ACHARJYA
KALYAN ACHARJYA 2017년 8월 10일
Dear Peter,
Are you looking for to calculate the phase difference between two nonsinusoidal signals? May be following link will help full to you, still having the problem, let me know.
https://goo.gl/37xkGQ
Jeno Boka
Jeno Boka 2017년 8월 11일
He is asking the delay of the filter, not in sinusoidal case. Of course it is trivial to tell the phase shift of the filter in a purely sinusiodal case, or when the signal is periodic.
The question is when the signal is not periodic, nor deterministic.
The sine wave is just an example, to demonstare the phenomenom.
Probably the answer is linked to the tap size of the filter, as it is a digital filter. But I was not able to fint a way to get the tap number of the filter, when using filt.

댓글을 달려면 로그인하십시오.

답변 (2개)

Jeno Boka
Jeno Boka 2017년 8월 14일
Anyone any idea?

Star Strider
Star Strider 2017년 8월 14일
The only way I can see to calculate this is to filter the same signal using filter and filtfilt, then compare them with the finddelay (link) function. Compute the phase shift from that information. (The finddelay function was introduced two years ago if I remember correctly. The documentation does not say when it was introduced.)
  댓글 수: 2
Jeno Boka
Jeno Boka 2017년 8월 28일
I was looking for a way to avoid the usage of the Signal Processing Toolbox.
But, yes your answer is clearly a solutuion.
Star Strider
Star Strider 2017년 8월 28일
If you want to avoid using the Signal Processing Toolbox, another option may be Curve fitting to a sinusoidal function (link), since it calculates the phase as one of the parameters. You can compare the parameters — particularly the phase parameter — of the unfiltered signal with those of the filtered signal.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by