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)';
BPF = ((lower_freq < abs(f)) & (abs(f) < upper_freq));
figure;
plot(f,BPF);
time = dt*(0:N-1)';
figure;
plot(time,signal);
signal=signal-mean(signal);
spektrum = fftshift(fft(signal))/N;
figure;
subplot(2,1,1);
plot(f,abs(spektrum));
spektrum = BPF.*spektrum;
subplot(2,1,2);
plot(f,abs(spektrum));
signal=ifft(ifftshift(spektrum));
HTH.
Rick
Best Answer