Time + Acceleration Fourier transform into Amplitude + Frequency
16 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jan
le 30 Sep 2022
Réponse apportée : Star Strider
le 30 Sep 2022
I am trying to transform measured data from time and accelerations into amplitude and frequency, but I really dont understand the process. I have this:
g=9.81
A = importdata('220927_1.txt')
A = A.data
% Front Left sprung mass
B = [A(:,1),A(:,3).*g]
N = pow2(nextpow2(length(B)));
y = fft(B,N);
plot(1:N,abs(y))
Time = B(:,1); % Time (s)
Acceleration = B(:,2); % Acceleration (m/s^2)
n = length(Acceleration);
Ts = Time(n)-Time(1); % Sample Time
Fs = 1/Ts; % Sampling Frequency
NFFT = 2^nextpow2(n); % Next power of 2 from length of data
Y = fft(Acceleration,NFFT)/n;
f = Fs/2*linspace(0,1,NFFT/2+1);
plot(f,abs(Y))
xlabel('Frequency (Hz)')
ylabel('Amplitude (m)')
I copied the script for Fourier transform from another support but I dont know how to fix it for my application.
Additionally I was recommended to reduce the noise which I didnt search yet, but its not neccessary to answer that here.
I attached the measurement file. For sprung mass (vehicle body) there should be natural frequency somewhere around 1 to 2 Hz, so there should be peak value in ploted result. (for unsprung its around 10 Hz)
0 commentaires
Réponse acceptée
Star Strider
le 30 Sep 2022
The ‘Time’ values are not unique (they likely need an additional digit of precision) so they had to be processed by taking the mean of the unique values for both variables. The rest of the code needed a bit of tweaking to get it to work correctly. The signal has broadband noise, so a frequency-selective filter will not remove much of it. I experimented by filtering it with the sgolayfilt function since you mentioned filtering, however filtering may not be necessary if yoiu are only interested in the spectral qualities of the signal.
Try something like this —
Uz = unzip('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1141115/220927_1.zip');
T1 = readtable(Uz{1}, 'VariableNamingRule','preserve')
g=9.81;
t = T1{:,1};
FLSA = T1{:,3}*g;
[Ut,~,ix] = unique(t, 'stable');
C = accumarray(ix, (1:numel(t)), [], @(x){mean([t(x),FLSA(x)])}); % Aggregate Repeated 'Time' Values
M = cell2mat(C);
ta = M(:,1);
FLSAa = M(:,2);
Ts = mean(diff(ta));
Fs = 1/Ts
% Tssd = std(diff(ta))
figure
plot(t,FLSA)
grid
xlabel('t')
ylabel('FLSA')
title('Original')
figure
plot(ta,FLSAa)
grid
xlabel('t')
ylabel('FLSA')
title('Aggregated')
FLSAa_filt = sgolayfilt(FLSAa, 3, 51); % Optional
figure
plot(ta,FLSAa_filt)
grid
xlabel('t')
ylabel('FLSA')
title('Aggregated & Filtered')
Time = ta; % Time (s)
Acceleration = FLSAa_filt; % Acceleration (m/s^2)
n = numel(Acceleration);
Ts = Time(n)-Time(1); % Sample Time
Fs = 1/Ts; % Sampling Frequency
NFFT = 2^nextpow2(n); % Next power of 2 from length of data
Y = fft(Acceleration-mean(Acceleration),NFFT)/n;
f = Fs/2*linspace(0,1,NFFT/2+1);
Iv = 1:numel(f);
figure
plot(f,abs(Y(Iv))*2)
grid
xlim([0 0.005])
xlabel('Frequency (Hz)')
ylabel('Amplitude (m)')
Experiment to get the desired result.
.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Discrete Fourier and Cosine Transforms dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



