clear;clc;
tic
load('vibdata.mat')
fs=5120;%实际采样频率
n = 2^14;%fft变换点数4096
nfft=n;%fft变换点数4096
fft_data1 = wdenoise(fft_data,5, ...
'Wavelet', 'db3', ...
'DenoisingMethod', 'Bayes', ...
'ThresholdRule', 'Median', ...
'NoiseEstimate', 'LevelIndependent');
for i=0:1
if i == 0
x=fft_data(1:n)
else
x=fft_data1(1:n);%取1秒不到的时域数据
end
fy=abs(fft(x,nfft));
fx=(1:nfft/2)*fs/nfft;
t=0:1/fs:nfft/fs-1/fs;
figure()
subplot(121)
plot(t,x);
xlabel('t/s');ylabel('幅值');title('原始时域信号');axis([0 nfft/fs -1 1])
subplot(122)
plot(fx,fy(1:nfft/2)*2/nfft);
xlabel('频率/Hz');ylabel('幅值');title('FFT频域信号');axis([0 fs/2 0 0.1])
end
%时间已过 0.098931 秒