MATLAB: How to create a 2-D plot to validate filter characteristics

anaylsisaudiodafxdsp

I am running a test signal (white noise) through filter so that i can validate the frequency response and magnitude.
Below is the code I'm using to test the filter
%Test 1
Fs = 44100
x = randn(1,44100); % Signal = randn (fs*dur,1) shall generate 1 channel signal with certain sampling frequency and duration
[b1,a1]=fourbandEQ(30,0,1, 300,0,1, 1000,0,1, 5000,0,1, Fs);
y = filter (b1,a1,x);
% y = filter(b,a,X) Y is output signal, X is input signal, b is array of
%denominator coefficients , a is numerator

Best Answer

  • I can’t run your code, but the easiest way to plot the transfer function is to divide the fft of the output by the fft of the input, then do the appropriate plots:
    Fn = Fs/2;
    tf = fft(y)./fft(x);
    Fv = linspace(0, 1, length(tf)/2+1)*Fn;
    Ix = 1:length(Fv);
    figure(1)
    subplot(2,1,1)
    plot(Fv, abs(tf(Ix)))
    grid
    ylabel('Amplitude')
    subplot(2,1,2)
    plot(Fv, angle(tf(Ix)))
    grid
    xlabel('Frequency')
    ylabel('Phase')
    Untested, but should work.