+ Post New Thread
Results 1 to 12 of 12
  1. #1
    Newbie level 4
    Points: 374, Level: 4

    Join Date
    Dec 2010
    Posts
    6
    Helped
    0 / 0
    Points
    374
    Level
    4

    Matlab FIR and IIR (little help with simple task)

    I am total beginner using Matlab so I need some help creating FIR and IIR filters with Mathlab.

    I have read audiofile:
    x=wavread('C:\Pinkpatka.wav',175142);

    and I should filter it with FIR, which have these factors: [-0.04, 0.1, 0.3, 0.4, 0.3, 0.1, -0.04]

    I must also filter it with IIR, which have factors b=[0.2939 0.2939], a=[1 -0.4231]

    I tried google right commands and actually found something. Problem is that no matter how much I tried commands didnt work.
    (sry for bad English)

  2. #2
    Full Member level 5
    Points: 4,114, Level: 15
    Achievements:
    7 years registered
    RBB's Avatar
    Join Date
    Jul 2007
    Location
    USA
    Posts
    304
    Helped
    70 / 70
    Points
    4,114
    Level
    15

    Re: Matlab FIR and IIR (little help with simple task)

    Have you tried the filter function?


    1 members found this post helpful.

    •   Alt30th December 2010, 19:00

      advertising

        
       

  3. #3
    Newbie level 4
    Points: 374, Level: 4

    Join Date
    Dec 2010
    Posts
    6
    Helped
    0 / 0
    Points
    374
    Level
    4

    Re: Matlab FIR and IIR (little help with simple task)

    Quote Originally Posted by RBB View Post
    Have you tried the filter function?
    Actually I tried it, but seems like it only filtered only 7 first samples and then erased everything after that. Of course it's possible that I made some mistake when I tried it. Like I said I am beginner with Matlab



  4. #4
    Full Member level 5
    Points: 4,114, Level: 15
    Achievements:
    7 years registered
    RBB's Avatar
    Join Date
    Jul 2007
    Location
    USA
    Posts
    304
    Helped
    70 / 70
    Points
    4,114
    Level
    15

    Re: Matlab FIR and IIR (little help with simple task)

    Why don't you paste the section of code, that calls the filter function.


    1 members found this post helpful.

  5. #5
    Newbie level 4
    Points: 374, Level: 4

    Join Date
    Dec 2010
    Posts
    6
    Helped
    0 / 0
    Points
    374
    Level
    4

    Re: Matlab FIR and IIR (little help with simple task)

    Quote Originally Posted by RBB View Post
    Why don't you paste the section of code, that calls the filter function.
    Because I dont have it anymore. I tried it yesterday and because it totally failed I didnt save it.



    •   Alt30th December 2010, 19:12

      advertising

        
       

  6. #6
    Full Member level 5
    Points: 4,114, Level: 15
    Achievements:
    7 years registered
    RBB's Avatar
    Join Date
    Jul 2007
    Location
    USA
    Posts
    304
    Helped
    70 / 70
    Points
    4,114
    Level
    15

    Re: Matlab FIR and IIR (little help with simple task)

    It should only be a couple lines long...

    x = wavread('C:\Pinkpatka.wav',175142);
    B = [-0.04, 0.1, 0.3, 0.4, 0.3, 0.1, -0.04];
    y = filter(B, 1, x);


    1 members found this post helpful.

  7. #7
    Newbie level 4
    Points: 374, Level: 4

    Join Date
    Dec 2010
    Posts
    6
    Helped
    0 / 0
    Points
    374
    Level
    4

    Re: Matlab FIR and IIR (little help with simple task)

    Quote Originally Posted by RBB View Post
    It should only be a couple lines long...

    x = wavread('C:\Pinkpatka.wav',175142);
    B = [-0.04, 0.1, 0.3, 0.4, 0.3, 0.1, -0.04];
    y = filter(B, 1, x);
    Thanks, that really helped.

    So IIR-filter would go like this?
    a=[1 -0.4241]
    b=[0.2929 0.2929]
    y = filter(b, a, x);



  8. #8
    Full Member level 5
    Points: 4,114, Level: 15
    Achievements:
    7 years registered
    RBB's Avatar
    Join Date
    Jul 2007
    Location
    USA
    Posts
    304
    Helped
    70 / 70
    Points
    4,114
    Level
    15

    Re: Matlab FIR and IIR (little help with simple task)

    That's looks right.


    1 members found this post helpful.

  9. #9
    Newbie level 4
    Points: 374, Level: 4

    Join Date
    Dec 2010
    Posts
    6
    Helped
    0 / 0
    Points
    374
    Level
    4

    Re: Matlab FIR and IIR (little help with simple task)

    Errmm.. It seems like I must also make spectrograms from signals.

    Command goes like this:
    S=spectrogram(x,window,noverlap,nfft,fs).
    So x is signal, window = ?, noverlap=?, nfft=? and fs=44100.

    I know that these are explained in here, but I don't really understand without good example.



    •   Alt30th December 2010, 20:12

      advertising

        
       

  10. #10
    Member level 3
    Points: 1,631, Level: 9
    Achievements:
    7 years registered
    Scrts's Avatar
    Join Date
    Mar 2009
    Location
    Kaunas, Lithuania
    Posts
    60
    Helped
    15 / 15
    Points
    1,631
    Level
    9

    Re: Matlab FIR and IIR (little help with simple task)

    firstly try only spectrogram(x), then check other options if needed.



  11. #11
    Newbie level 4
    Points: 374, Level: 4

    Join Date
    Dec 2010
    Posts
    6
    Helped
    0 / 0
    Points
    374
    Level
    4

    Re: Matlab FIR and IIR (little help with simple task)

    Quote Originally Posted by Scrts View Post
    firstly try only spectrogram(x), then check other options if needed.
    It's only say: "??? Error using ==> spectrogram at 113
    X must be a vector (either row or column)."

    Edit: Oookey.. Audiofile must be mono not stereo or spectrogram doesn't work.
    Last edited by Draculaardi; 31st December 2010 at 13:56.



  12. #12
    Full Member level 5
    Points: 4,114, Level: 15
    Achievements:
    7 years registered
    RBB's Avatar
    Join Date
    Jul 2007
    Location
    USA
    Posts
    304
    Helped
    70 / 70
    Points
    4,114
    Level
    15

    Re: Matlab FIR and IIR (little help with simple task)

    You can access just a single vector in the array via...
    x(1,:) x(2,:)
    or
    x(:,1) x(:,2)
    depending on the array size



--[[ ]]--