MATLAB
Plotting an FRF from a Transfer Function in MATLAB
A short note for quickly plotting the frequency response function of a single-degree-of-freedom system in MATLAB.
1 min read
Seeing the frequency response function (FRF) of a single-degree-of-freedom (SDOF) system is the fastest way to build structural-dynamics intuition. Here's a practical setup in MATLAB.
SDOF Parameters#
m = 1; % mass [kg]
k = 1e4; % stiffness [N/m]
zeta = 0.05; % damping ratio [-]
wn = sqrt(k/m); % natural angular frequency [rad/s]
c = 2*zeta*sqrt(k*m); % damping coefficientFRF Computation and Plot#
f = linspace(0, 50, 2000); % frequency [Hz]
w = 2*pi*f;
H = 1 ./ (k - m*w.^2 + 1i*c*w); % receptance FRF
figure;
subplot(2,1,1);
semilogy(f, abs(H)); grid on;
ylabel('|H(\omega)|'); title('SDOF FRF');
subplot(2,1,2);
plot(f, angle(H)*180/pi); grid on;
xlabel('Frequency [Hz]'); ylabel('Phase [\circ]');What to look for
You should see a clear peak at the natural frequency in the magnitude curve, and a 180° shift at the same point in the phase curve. As you increase damping, the peak gets lower and broader.
Running this small script while changing the parameters is one of the most effective ways to explain the relationship between resonance and damping.