applying FFT on Pressure drop signals

3 次查看(过去 30 天)
I want to apply FFT on these pressure drop signals i have. The signals are actually voltage signals which are converted to pressure drop with the help of pressure callibration equations. Here's what i've done so far but i feel that something's wrong with this algorithm. can any one please have a look.
Also i have tones of similar data thats needed to be processed in a similar fashion. now i know a 'for' loop can solve the problem but coding is not my strong suit. please help!!
Additionally, why do we use 2^n in FFT?
[D] = readtable('test_data_19-09-18_1137_0001.xlsx'); %inputting a series of data ex. like an array [1,2,3,4,5]
% [D] = readtable('virgin_data/test_data_19-09-17_1615_0001.xlsx');
% [next_D] = readtable('test_data_19-09-18_1143_0001.xlsx');
D.Voltage_1 = 1380.1*D.Voltage_1 - 1393.8; %PT010-1
D.Voltage_2 = 1372.2*D.Voltage_2 - 1372; %PT053-2
D.Voltage_3 = 1393.2*D.Voltage_3 - 1389.8; %PT051-3
D.Voltage_4 = 1373.6*D.Voltage_4 - 1385.3; %PT050-4
D.Voltage_5 = 1375.3*D.Voltage_5 - 1398.9; %PT062-5
D.Voltage_6 = 1387.5*D.Voltage_6 - 1434.9; %PT061-6
D.Voltage_7 = 1375.3*D.Voltage_7 - 1394.9; %PT005-7
Accel = D(:,2:8);
disp(class(Accel.Voltage_2)); %Displays data type in command window.
Accel.Voltage_1 = Accel.Voltage_1 / double(512);
Accel.Voltage_2 = Accel.Voltage_2 / double(512);
Accel.Voltage_3 = Accel.Voltage_3 / double(512);
Accel.Voltage_4 = Accel.Voltage_4 / double(512);
Accel.Voltage_5 = Accel.Voltage_5 / double(512); % why 512
Accel.Voltage_6 = Accel.Voltage_6 / double(512);
Accel.Voltage_7 = Accel.Voltage_7 / double(512);
% Accel = Accel./ 123;
Ts = 45 ; % Sampling Interval (Number of samples)
Fs = 1000; % Sampling Frequency (The actual number of samples)
Fn = Fs/2; % Nyquist Frequency (Sampling frequency, your sampling frequency must be atleast 2x the frequency of your data
L = size(D,1);
FT_Accel = fft(Accel.Voltage_1-mean(Accel.Voltage_1))/L; % Subtrace Constant Offset & Calculate Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector (This is how your graph will display intervals, defines what can possibly land on x or y axis) Similar to resolution of you graph
Iv = 1:numel(Fv); % Index Vector (index will go through data one at a time, its defined so MATLAB knows how to iterate through your data defined by your .xlsx
figure
subplot(3,1,1) %Display Graph
plot(Fv, abs(FT_Accel(Iv,1))*2) %Plot of graph

回答(2 个)

Mathieu NOE
Mathieu NOE 2020-12-8
hello
FYI, this is my prefered fft subfunction ,
function [freq_vector,fft_spectrum] = myfft_peak(signal, Fs, nfft, Overlap)
%FFT peak spectrum of signal (example sinus amplitude 1 = 0 dB after fft).
% signal - input signal,
% Fs - Sampling frequency (Hz).
% nfft - FFT window size
% Overlap - buffer overlap % (between 0 and 0.95)
samples = length(signal);
% fill signal with zeros if its length is lower than nfft
if samples<nfft
s_tmp = zeros(nfft,1);
s_tmp((1:samples)) = signal;
signal = s_tmp;
end
% window : hanning
window = hanning(nfft);
window = window(:);
% compute fft with overlap
offset = fix((1-Overlap)*nfft);
spectnum = 1+ fix((samples-nfft)/offset); % Number of windows
% % for info is equivalent to :
% noverlap = Overlap*nfft;
% spectnum = fix((samples-noverlap)/(nfft-noverlap)); % Number of windows
% main loop
fft_spectrum = 0;
for i=1:spectnum
start = (i-1)*offset;
sw = signal((1+start):(start+nfft)).*window;
fft_spectrum = fft_spectrum + (abs(fft(sw))*4/nfft); % X=fft(x.*hanning(N))*4/N; % hanning only
end
fft_spectrum = fft_spectrum/spectnum; % to do linear averaging scaling
% one sidded fft spectrum % Select first half
if rem(nfft,2) % nfft odd
select = (1:(nfft+1)/2)';
else
select = (1:nfft/2+1)';
end
fft_spectrum = fft_spectrum(select);
freq_vector = (select - 1)*Fs/nfft;
end

Shadaab Siddiqie
Shadaab Siddiqie 2020-12-9
Here is a FFT resource which might help. Coming to "why we use 2^n in FFT" in MATLAB here is a similar question which might help you.

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by