fid = fopen('LEM_BHN.TXT');
data = textscan(fid,'%f');
fclose(fid);
x = data{1};
N = length(x);
dt = 0.01
t = [0:dt:(N-1)*dt];
y = data(:,N);
m = sum(y,2);
Fs = 250;
LD = length(m);
YD = fft(m);
P2D = abs(YD/LD);
P1D = P2D(1:LD/2+1);
fD = Fs*(0:(LD/2))/LD;
figure(1)
plot(fD,P1D)
hold on
title ('Analysis Spectrum')
ylabel ('Amplitude')
xlabel ('Frequency (Hz)')
axis([min(fD) max(fD) min(P1D) max(P1D)])
m = input('Input the bottom freq value = ');
n = input('Input the top freq value = ');
figure(2)
for i = 1:N
subplot(1,2,1)
plot(data(:,i)+300*i,t,'k');
set(gca,'Ydir','reverse');
title ('Before Bandpass Filter')
legend('Raw')
ylabel('Time (s)')
xlabel('Offset (m)')
hold on
axis([min(data(:,1)+300*1) max(data(:,i)+300*i) min(t) max(t)])
end
for i = 1:N
y = data(:,i);
Fs = 250;
[b,a] = butter(2,[m n]/(Fs/2));
yabp = filter(b,a,y);
subplot(1,2,2)
plot(yabp+300*i,t,'k')
set(gca,'Ydir','reverse');
legend('band')
title ('After Bandpass Filter')
legend('Bandpass')
ylabel ('Time (s)')
xlabel ('Offset (m)')
hold on
axis([min(yabp+300*1) max(yabp+300*i) min(t) max(t)])
end
0 Comments
Sign in to comment.