Effacer les filtres
Effacer les filtres

How to plot the Acceleration as a function of Frequency?

12 vues (au cours des 30 derniers jours)
Sarah Jæger
Sarah Jæger le 21 Avr 2021
I have made some measurements of acceleration of a floor slab and i have the acceleration as a function of time.
How can I plot the Acceleration as a function of Frequency, like the photo below?
I have been given a code where I get a plot of the "Singular Value [dB per unit]" vs "frequency ", but i am unsure what this Singular Value signifies.
Is it possible to plot the acceleration vs frequency ?
Ns = 2 * (Nf - 1);
yd = fftfilt1(y.', Ns, dt, 'detrend', 0); % remove trends from accelaration
% measurements
yf=fftfilt1(yd, Ns, dt, 'decimate', r); % decimate the accelaration
% measurements
dtr = dt*r; % sampling interval after decimation
[num_channels,N] = size(yf);
df = 1/(N*dtr);
nf = N/2+1;
f = (0:nf-1)'*df;
Yf = fft(yf.'); % from time to frequency domain
Yf = Yf(1:nf,:).';
for i=1:nf
[Uf,Sf,Vf] = svd(Yf(:,i));
S(i,1) = Sf(1);
end
figure(2); % singular values plot
plot(f, 10*log10(S));
title('Sigular Value');
xlabel('Frequency [Hz]');
ylabel('Singular Value [dB per unit]');

Réponses (1)

Milan Bansal
Milan Bansal le 31 Mai 2024
Hi Sarah Jæger,
It is possible to plot the acceleration vs frequency graph. To plot acceleration as a function of frequency, it is required to calculate the Fourier Transform of the time-domain acceleration data. The MATLAB code you have provided seems to focus on Singular Value Decomposition (SVD) of the frequency domain data, which is not necessary for a straightforward acceleration vs. frequency plot.
Please refer to the below steps to ca:
  1. Load your acceleration data.
  2. Remove any trends using the detrend function.
  3. Compute the Fourier Transform using fft function.
  4. Plot the magnitude of the Fourier Transform against frequency.
Here is a simplified version of the MATLAB Code to achieve this. Please note that we have a assumed a time-domain accereration data for example.
% Load your acceleration data (assuming it's stored in variable 'y')
Fs = 1000; % Sampling frequency in Hz
dt = 1/Fs; % Sampling period in seconds
L = 1500; % Length of the signal (number of samples)
time = (0:L-1)*dt; % Time vector
% Simulate acceleration data
f = 5; % Frequency
A = 0.7; % Amplitude
y = A*sin(2*pi*f*time).*(2.71.^(time)) + 1*cos(24*pi*f*time);
plot(y)
title('Acceleration vs. time');
% Assuming 'y' is a vector containing your time-domain acceleration data
N = length(y); % Number of data points
dt = 0.01; % Sampling interval (modify this based on your actual data)
% Remove any trends from the data (optional)
y = detrend(y);
% Compute the FFT
Yf = fft(y);
% Define the frequency axis
df = 1/(N*dt); % Frequency resolution
nf = floor(N/2)+1;
f = (0:nf-1)'*df;
% Extract the positive frequency components
Yf = Yf(1:nf);
% Compute the magnitude of the FFT (convert to acceleration)
acceleration_magnitude = abs(Yf);
% Plot acceleration as a function of frequency
figure;
plot(f, acceleration_magnitude);
title('Acceleration vs. Frequency');
Please refer to the following documentation links to learn more about detrend and fft functions.
Hope this helps

Catégories

En savoir plus sur Vibration Analysis dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by