How is frequency response calculated as function of sample data frequency?

1 view (last 30 days)
Sample frequency is 100Hz, test frequency is 30Hz
h[k]= 0, 0.25, 0.25, 0.25, 0.25 k=0, 1, 2, 3, 4

Answers (1)

Mathieu NOE
Mathieu NOE on 19 May 2022
hello
so h is a FIR filter
see code below for Bode plot and time domain simulation on sine wave at 30 and 25 Hz (the notch frequency)
h = [0, 0.25, 0.25, 0.25, 0.25]; % FIR filter coefficients
Fs = 100; % sampling frequency
%% FIR filter Bode plot
freq = linspace(1,Fs/2.56,300);
h_frf = freqz(h,1,freq,Fs);
figure(1)
subplot(2,1,1),semilogx(freq,20*log10(abs(h_frf)));
title('FRF');
xlabel('Freq (Hz)');
ylabel('Amplitude (dB)');
subplot(2,1,2),semilogx(freq,angle(h_frf)*180/pi);
xlabel('Freq (Hz)');
ylabel('Phase (°)');
%% apply to sine wave at 30 Hz
dt = 1/Fs;
samples = 100;
f = 30; % signal freq (Hz)
t = (0:samples -1)*dt;
x = 3*sin(2*pi*f*t+1);
y = filter(h,1,x);
figure(2)
plot(t,x,t,y);
title('FRF');
xlabel('Time (s)');
ylabel('Amplitude');
legend('input','output');
%% apply to sine wave at 25 Hz
f = 25; % signal freq (Hz)
x = 3*sin(2*pi*f*t+1);
y = filter(h,1,x);
figure(3)
plot(t,x,t,y);
title('FRF');
xlabel('Time (s)');
ylabel('Amplitude');
legend('input','output');

Community Treasure Hunt

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

Start Hunting!