tjakeman
Mechanical
- Oct 21, 2009
- 29
Hello, and firstly appologies, I am a novice matlab user.
I want to filter some frequencies from a time domain signal (filter out everything below say 7 Hz). I was expecting to:
FFT time signal to frequency domain
Apply filter to frequency domain signal
inverse FFT filtered signal back to time domain.
What is wrong with this approach? When I plot the results, it seems to have applied the filter to the time domain signal....
Many thanks, Tom
my .m file so far:
function Hd = tjfilter
Fs = 200; % Sampling frequency
T = 1/Fs; % Sample time
L = 16384; % Length of signal(no. of data lines)
t = (0:L-1)*T; % Time vector
a = load('response_to_z.txt');
t = a
,1);
x = a
,2);
figure(1)
plot(t,x)
X = fft(x);
N = 200; % Order
Fstop = 7; % Stopband Frequency
Fpass = 10; % Passband Frequency
Wstop = 1; % Stopband Weight
Wpass = 1; % Passband Weight
dens = 20; % Density Factor
% Calculate the coefficients using the FIRPM function.
b = firpm(N, [0 Fstop Fpass Fs/2]/(Fs/2), [0 0 1 1], [Wstop Wpass], ...
{dens});
Hd = dfilt.dffir(b);
Y=filter(Hd,X);
fv = [0:0.005:100];
figure(2)
plot(fv,X);
figure(3)
plot(fv,Y);
y = (ifft(Y));
figure(4)
plot(t,y)
I want to filter some frequencies from a time domain signal (filter out everything below say 7 Hz). I was expecting to:
FFT time signal to frequency domain
Apply filter to frequency domain signal
inverse FFT filtered signal back to time domain.
What is wrong with this approach? When I plot the results, it seems to have applied the filter to the time domain signal....
Many thanks, Tom
my .m file so far:
function Hd = tjfilter
Fs = 200; % Sampling frequency
T = 1/Fs; % Sample time
L = 16384; % Length of signal(no. of data lines)
t = (0:L-1)*T; % Time vector
a = load('response_to_z.txt');
t = a
x = a
figure(1)
plot(t,x)
X = fft(x);
N = 200; % Order
Fstop = 7; % Stopband Frequency
Fpass = 10; % Passband Frequency
Wstop = 1; % Stopband Weight
Wpass = 1; % Passband Weight
dens = 20; % Density Factor
% Calculate the coefficients using the FIRPM function.
b = firpm(N, [0 Fstop Fpass Fs/2]/(Fs/2), [0 0 1 1], [Wstop Wpass], ...
{dens});
Hd = dfilt.dffir(b);
Y=filter(Hd,X);
fv = [0:0.005:100];
figure(2)
plot(fv,X);
figure(3)
plot(fv,Y);
y = (ifft(Y));
figure(4)
plot(t,y)