[英]MATLAB: FFT a signal to frequency and IFFT back to time domain, not exactly the first signal
[英]fft Matlab vibration time domain to frequency measurement duration= 60 s
我正在嘗試將時域中的振動信號轉換為頻域(使用 fft)以顯示幅度響應。 但是圖表是這樣顯示的。 你能看看我的go哪里錯了嗎?
關於數據是從 1/4/2015 0:00:00 - 15/4/2015 1:46:00 開始的時域往復式壓縮機的振動有 20267 行,測量持續時間 = 60 秒或 1 分鍾,RPM壓縮機的轉速 = 372.99152 RPM 鏈接到數據中的數據集 x45= 振動 (m/s^2) 和 x52 = 壓縮機的轉速
%% load vibration data in csv file
filename = 'data.csv';
T = readtable(filename);
T1 = T(:,1:2);
x45 = T1{:,2};
plot(T.time,T.x45);
xlabel('Time in seconds');
ylabel('Amplitude of signal');
dc3 = dsp.DCBlocker('Algorithm','Subtract mean'); % I use mean to remove dc-offset
y3 = dc3(T.x45);
%% Use FFT convert time domain signal into frequency domain
% FFT output follows complex notation (a+ib)
X45 = fft(y3); % X45 is the frequency domain representation
%% Retrieve the magnitude information from X45
X45_mag = abs(X45);
%% Retrieve the phase information from X45
X45_phase = angle(X45);
%% Frequency bins
N = length(x45);
Ts = 60; % measurement duration= 60 s or 1 minute
Fs = 1 / Ts ;
Fbins = ((0: 1/N: 1-1/N)*Fs).';
%% Plot magnitude response
helperFFT(Fbins,X45_mag,'Magnitude Response')
%% Plot phase response
helperFFT(Fbins,X45_phase,'Phase Response')
function helperFFT(bin, yVal,titleStr)
%Copyright 2014 The MathWorks, Inc
close all;clc;
figure;
plot(bin, yVal,'Color',[0,0,1],'LineWidth',1.5); box on; grid on;
xlabel('Frequency (Hz).');
if strcmp(titleStr,'Phase Response');
ylabel('Radians');
title('FFT - Phase Response');
else
ylabel('Magnitude');
title('FFT - Magnitude Response');
end
您的幅度譜看起來不錯,但您只需要 plot 一半的頻譜(實際信號具有復雜的共軛對稱性)。
另請查看 MATLAB 函數,如periodogram ,它為您完成了很多上述工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.