MATLAB: USE fft(x) as a highpass filter

fftfftshiftfourierfsifftsampling rate

Hi,
I want to use the fft(x) function to create an highpass filter. I want to ask if the following procedure is correct:
1) take the signal x and make an fft(x).
2) Set frequencies up to 0.5 Hz to zero.
3) Make ifft(spectrum).
Is it right to set the first data points to zero or is there anything to pay attention to (e.g.: symmetry of the fft…). So if I set the first data points to zero, is this enough?
Thanks for your efforts!

Best Answer

Here are some suggestions for improving the code.
I have inserted several new lines of code indented from the original code, and eliminated some lines of the original code by making them into comments:
signal=load(files{i});
dt = 0.008;
Fs = 1/dt;
N = size(signal,1);
dF = Fs/N;
f = (-Fs/2:dF:Fs/2-dF)';
% Band-Pass Filter:
BPF = ((lower_freq < abs(f)) & (abs(f) < upper_freq));
figure;
plot(f,BPF);
% time=0.008:0.008:size(signal,1)*0.008;
time = dt*(0:N-1)';
figure;
plot(time,signal);
% NFFT=2^nextpow2(size(signal,1));
signal=signal-mean(signal);
% spektrum = fft(signal,NFFT)/(size(signal,1));
spektrum = fftshift(fft(signal))/N;
figure;
subplot(2,1,1);
plot(f,abs(spektrum));
% spektrum(lower_freq:upper_freq,1)=0;
% spektrum(size(spektrum,1)- upper_freq+1:size(spektrum,1)-lower_freq+1,1)=0;
spektrum = BPF.*spektrum;
subplot(2,1,2);
plot(f,abs(spektrum));
% signal=ifft(spektrum); %inverse ifft
signal=ifft(ifftshift(spektrum)); %inverse ifft
HTH.
Rick