I have a data of velocity (get from accelerometer) and force data (get from hammer). Now, I need to get mobility from them. I already know that mobility=velocity/force. But I don't know how code it. I just begin learning about signal processing for a week.
Prashant Kumar answered .
2025-11-20
function [X, freqs] = easy_fft(x, fs) L = length(x); NFFT = 2^nextpow2(length(x)); X = fft(x, NFFT); X = 2/L*X(1:NFFT/2 + 1); % 2/L is the required scaling freqs = fs/2*linspace(0,1,NFFT/2+1); % Frequency vector end
Then do
fs = 1/y(2, 1); % Convert time step to sample rate [A, freq] = easy_fft(y(:, 2), fs); % Acceleration [F, ~] = easy_fft(y(:, 3), fs); % Force
H = A./F;
omega = 2*pi*freq; % Convert to rad/s mobility = H./(1i*omega); % Acceleration = i*omega*Velocity for a periodic steady-state response
To replicate the plot you showed, take the absolute value of mobility and put it on a log scale vs. frequency.
semilogy(freq, abs(mobility));
Apologies if there are any bugs in what I wrote, I didn't test it on anything. Hopefully you get the idea.