Matlab filter questions

MATLABsignal processing

I have an array of data, it is in time domain. Each data stands for the magnitude, and that data is sampled in a frequency of 10,000Hz.
I want to do a band pass filter between two frequencies f1, and f2. I think I need to do a low pass filter and a high pass filter. The signal does an FFT then goes through the two filters then do an inverse FFT.
My questions: is there an easy way to do the low pass and high pass filter? I don't know how to derive the transfer function based on the two cut off frequencies.

Does anyone know how?

Thanks

Best Answer

Building on Tristan's answer, here is some Octave Code which might or might not be Matlab compatible. The butter function derives the transfer function coefficients for you. alt text.alt text

hz = 8000;
x = [1:1:hz*10];
t = x./hz;
pi = 3.1415;

% Create signal with 10 hz, 200 hz and 500 hz components
raw_signal = sin(10*2*pi*t)+sin(200*2*pi*t)+sin(500*2*pi*t);

% View Raw Signal Over .1 Second Window
plot(t, raw_signal)
title('Raw Signal with 10Hz, 200Hz, 500Hz Components')
xlabel('Time (Sec)')
ylabel('Amplitude')
set(gca,'XLim', [5, 5.1]);

% Create Band Pass Butterworth Filter
[S_numer, S_denom] = butter(5, [100/hz 350/hz]);
band_passed_signal = filter(S_numer, S_denom, raw_signal);

% View Band Pass Filtered Signal Over .1 Second Window
plot(t, band_passed_signal)
title('Band Pass Filtered Signal')
xlabel('Time (Sec)')
ylabel('Amplitude')
set(gca,'XLim', [5, 5.1]);
Related Topic