Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Matlab FIR and IIR (little help with simple task)

Status
Not open for further replies.

Draculaardi

Newbie level 4
Joined
Dec 30, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,320
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)
 

Draculaardi

Newbie level 4
Joined
Dec 30, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,320
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
 

RBB

Full Member level 5
Joined
Jul 2, 2007
Messages
304
Helped
71
Reputation
142
Reaction score
36
Trophy points
1,308
Location
USA
Activity points
2,559
Why don't you paste the section of code, that calls the filter function.
 

Draculaardi

Newbie level 4
Joined
Dec 30, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,320
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.
 

RBB

Full Member level 5
Joined
Jul 2, 2007
Messages
304
Helped
71
Reputation
142
Reaction score
36
Trophy points
1,308
Location
USA
Activity points
2,559
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);
 

Draculaardi

Newbie level 4
Joined
Dec 30, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,320
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);
 

Draculaardi

Newbie level 4
Joined
Dec 30, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,320
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.
 

Draculaardi

Newbie level 4
Joined
Dec 30, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,320
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:

RBB

Full Member level 5
Joined
Jul 2, 2007
Messages
304
Helped
71
Reputation
142
Reaction score
36
Trophy points
1,308
Location
USA
Activity points
2,559
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
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top