M-file for calculating frequency response from impulse response

Discussion in 'MATLAB' started by Wayne Little, Dec 7, 2009.

  1. Wayne Little

    Wayne Little Guest

    Hello,

    I am trying to calculate the magnitude of the frequency response by taking the FFT of an RC circuit's impulse response. I can obtain and plot the step and impulse response with ease, but I am having difficulty with the plot format for the magnitude of the FFTed impulse response.
    Can someone offer a few tips?


    %A simple low pass RC circuit
    %R = 1k, C= 1uF
    num=[1000];
    den=[1 1000];
    Hs=tf(num,den);
    t=0:0.0001:0.01 % Start at T=0, .001 steps, stop time 0.01
    figure(1);
    clf;
    subplot(2,1,1);
    step(Hs,t);
    grid;
    subplot(2,1,2);
    impulse(Hs,t);
    figure(2);
    clf;
    FFTMag=(abs(fft(impulse(Hs,t))));
    x=logspace(-100,100,100);
    loglog(x,20*log(FFTMag));
    xlabel('Frequency ');
    ylabel('|H(w)| ');
    title('Magnitude Spectrum of Impulse Response');
     
    Wayne Little, Dec 7, 2009
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.