Matlab Lowpass filter

Thread Starter

audio_freq

Joined Apr 7, 2010
1
I am pulling my hair out trying to write a lowpass filter for audio.
Being an audio engineer not a programmer this is totally alien to me, I have just about got the hang of using Matlab and now I'm being asked to write code!!

This is what I've written so far. If any kind person can help I'd be very grateful.
% Low Pass Filter at 1 kHz.

cutoff = 1000 / (fs/2);
% identifies all frequencies below 1000Hz

below_cutoff = spectrum(1:cutoff);


changed_spectrum = [below_cutoff;zeros];



I know it's probably complete garbage (it certainly doesn't work) but am I anywhere near on the right track? I just don't get it.
 
Last edited:

gizmoman0

Joined Jan 21, 2010
26
the easiest implementation would probably be with an finite impulse response (FIR) filter which you will need to research. There are a few things you need to choose before beginning including fsample, n sample points, etc. Basically, you take your array of data that you want to be filtered and multiply it by a set of filter coefficients designed for a low pass filter response. By multipling each data point by each filter coefficient, your output will respond accordingly. I know this is impossible to understand without knowing anything about the topic but do a little reading and you will pick a few things up. here is an example in C code which you can sorta port to matlab or help you understand better.

http://www.netrino.com/Embedded-Systems/How-To/Digital-Filters-FIR-IIR
 
I'd use FDA tool if you're not interested in learning about implementation...

Depending on your filter, you can generate the code from FDA tool, or you can generate coefficients and use filter() or firpm() or similar... lots of easy options from FDA tool...
 
Top