Posted on 2006-04-26
Last Modified: 2016-02-10
Hi experts,
    I am very new at MATLAB but I am trying to pick a set of periodic and aperiodic signal (can be any signal) and then pass them trhough filters (like ideal low-pass, butterworth filters), and see the output signal and spectra.

but have no idea how to do it.  Any help would be appreciated.  Thank you in advance.
Question by:hsuyf
    LVL 2

    Accepted Solution

    Before you filter your data, you need to interpolate onto an equispaced timebase.
    You might do this using something like :
    >> samplePeriod = 0.1; %seconds
    >> t = [min(waveformAperiodic):samplePeriod:max(waveformAperiodic)]';
    >> waveformAperiodicEq = [t,interp1(waveformAperiodic(:,1),waveformAperiodic(:,2),t)];

    Then you need choose a time constant for your first order filter and from this calculate a filter coefficient :
    >> timeConst = 2; %seconds
    >> filterCoeff = exp(-samplePeriod/timeConst);

    Then you are ready to filter and then plot your data :
    >> waveformAperiodicFiltered = [t, filter((1-filterCoeff ), [1 -filterCoeff ], waveformAperiodicEq(:,2), waveformAperiodicEq(1,2))];
    >> plot(waveformAperiodic(:,1), waveformAperiodic(:,2), waveformAperiodicFiltered(:,1), waveformAperiodicFiltered(:,2))

    Author Comment

    Hi Gordon

    thank you very much for your help. Could you please give me a code example like you hlep me in the "amplitude/phase spectra" question? I am thinking about using a .wav file for my aperiodic source (instead of createing it) and pass it through filters (like ideal low-pass, butterworth filters). do you think it would be more easy to do?

    I really need have some codes for this project, if you feel some parts (use in different filters) are difficult to do, please let me know. I will divide them into new question.
    LVL 2

    Expert Comment

    Hello hsuyf,

    The response I gave you above already does contain example Matlab code to achieve what you asked (using Matlab's standard filter function) ... so I am not clear what else you are asking for.

    If you need extra information, please could you accept this answer, and then ask a new one ?


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Foreword (May 2015) This web page has appeared at Google.  It's definitely worth considering! How to Know You are Making a Difference at EE In August, 2013, one …
    Have you ever thought of installing a power system that generates solar electricity to power your house? Some may say yes, while others may tell me no. But have you noticed that people around you are now considering installing such systems in their …
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video discusses moving either the default database or any database to a new volume.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now