Time + Acceleration Fourier transform into Amplitude + Frequency
12 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Star Strider
2022-9-30
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!