Magnitude and Phase response of a Lowpass filter
Mostra commenti meno recenti
I have a problem with understanding the phase response of lowpass filter in MATLAB(I'm writing my own code not using inbuilt functions to find phase response & Matlab). I am trying to pass sine signals of different frequencies into a lowpass filter with a certain passband frequency. Later, magnitude response is obtained by the change in the output amplitude divided by input amplitude . Whereas phase response is the angle of (output amplitude/input amplitude)???. I am getting correct magnitude response, but my phase response is zero. I don't understand why ??
I mean even though there isnt a phase term in the test signal ,there should be some phase change due to the lowpass filter at least. I almost spent more than two weeks on this and still unable to understand .
Im attaching the graphs for the amplitude response and phase response ,along with the code.
fs=1000;
f=1:15;
t = 0:1/fs:10-1/fs;
x= sin(2*pi*t'*f);
[Y,d]= lowpass(x,10,fs);
figure;
plot(t,x);
hold on
plot(t,Y);
for i=1:15
figure(i);
plot(t,x(:,i));
hold on
plot(t,Y(:,i));
title ('Original/ Filtered Data')
%%%%%%%%% peak to peak amp %%%%%%%%%%%%
input(i)=(rms( x(:,i))/0.707)*2;%%%% inp peak to peak
output(i)=(rms(Y(:,i))/0.707)*2 ;%%%%%% out peak to peak
change(i)=output(i)./input(i);%%%%%% change in out peak to peak to input
phase(i)=angle(change(i));
end
figure;
subplot(2,1,1);
plot(f,mag2db(abs(change)));
title('Frequency response of the filter using abs(Out/Inp)')
xlabel('Frequency');
ylabel ('Change in output/input P-P' );
subplot(2,1,2);
plot(f,phase);
title('Phase response of the filter using angle(Out/Inp)')
xlabel('Frequency');
ylabel ('phase' );
2 Commenti
Paul
il 3 Set 2020
Are you trying to understand why the lowpass function in the Signal Processing Toolbox does not introduce a phase shift in the output?
Or are you trying to develop a procedure to determine the frequency response of an unknown system by injecting a series of sine waves of various frequencies?
Suvvi Kuppur Narayana Swamy
il 4 Set 2020
Risposta accettata
Più risposte (1)
Robert U
il 3 Set 2020
0 voti
Hi Suvvi Kuppur Narayana Swamy:
The function angle() is calculating the phase angle of a complex number. Since all values are real there would always be a phase angle of zero. The function lowpass() compensates for delays according to documentation. If you would calculate the phase angle between the input and the output function it should remain close to zero anyway.
Example without using signal toolbox including calculations on transfer function:
Kind regards,
Robert
2 Commenti
Suvvi Kuppur Narayana Swamy
il 3 Set 2020
Robert U
il 3 Set 2020
Hi Suvvi Kuppur Narayana Swamy:
I assume that actually you are interested in analogue system transfer functions.
f=1:15;
% second order filter with 10 Hz pass band
H = @(f,s) 1./(1./(2*pi*f).^2*s.^2 + 2./(2*pi*f)*s + 1);
H10 = @(s) H(10,s);
% magnitude estimation
magn = abs(H10(1j*2*pi*f));
% phase estimation
phase = rad2deg( angle(H10(1j*2*pi*f)) );
figure;
subplot(2,1,1);
semilogx(f,mag2db(magn));
title('Frequency response of the filter using abs(Out/Inp)')
xlabel('Frequency');
ylabel ('Change in output/input P-P' );
subplot(2,1,2);
semilogx(f,phase);
title('Phase response of the filter using angle(Out/Inp)')
xlabel('Frequency');
ylabel ('phase' );
% check against inbuilt functions
H_tf = @(f) tf(1,[1./(2*pi*f).^2 2./(2*pi*f) 1]);
figure;
bodeplot(H_tf(10),2*pi*f)
If you want to calculate the time discrete transfer functions you would have to convert the transfer functions from Laplace-domain into z-Domain. Inbuilt is a function c2d().
Kind regards,
Robert
Categorie
Scopri di più su Transforms in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


