Frequency Response Analysis in MATLAB

MATLAB Illustration

Frequency Response Plots in MATLAB

Frequency response analysis shows how a system (LTI system, filter, amplifier, etc.) responds to different input frequencies. Key plots: Bode plot (magnitude & phase vs. frequency), Nyquist plot (complex plane), Nichols plot.

Key Functions

  • bode(): Bode plot (mag/phase in dB/degrees vs. log frequency).
  • nyquist(): Polar plot of G(jω) in complex plane.
  • nichols(): Nichols chart (mag in dB vs. phase).
  • freqz(): For digital filters (discrete-time).
  • margin(): Stability margins (gain/phase margins).

Basic Steps

  1. Define System: Transfer function sys = tf([1 2], [1 3 2]) or state-space.
  2. Plot: bode(sys); grid on;.
  3. Customize: Set frequency range, labels, limits.
  4. Analyze: Read bandwidth, resonance peaks, phase margins.

Example Code

MATLAB
% Define a second-order system (low-pass filter)  num = [1];
den = [1 2 50];
% ω_n = 7.07 rad/s, ζ = 0.141  sys = tf(num, den);
% Bode plot  
figure;
bode(sys);
grid on;
title('Frequency Response: Bode Plot');
xlabel('Frequency (rad/s)');
% Or manual control  [mag, phase, w] = bode(sys);
figure;
sub
plot(2,1,1);
semilogx(w, 20*log10(squeeze(mag)));
grid on;
ylabel('Magnitude (dB)');
title('Bode Plot');
sub
plot(2,1,2);
semilogx(w, squeeze(phase));
grid on;
ylabel('Phase (deg)');
xlabel('Frequency (rad/s)');

For Digital Filters

MATLAB
% FIR/IIR filter  b = fir1(30, 0.3);
a = 1;
% 30-tap FIR low-pass  [h, f] = freqz(b, a, 512, 1000);
% fs = 1kHz  
figure;
plot(f, 20*log10(abs(h)));
grid on;
title('Digital Filter Frequency Response');
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');

Applications

  • Control systems: Stability, bandwidth analysis.
  • Filters: Cutoff frequency, roll-off verification.
  • Amplifiers: Gain flatness, phase shift.
  • Power electronics: Converter transfer functions.

Pro Tips: Use bodemag(), bodephase() for separate plots. Add rlocus() for root locus comparison. Always check units (rad/s vs Hz).

Verified Feedback

What Engineering Students Say

Real feedback from students across top engineering universities worldwide.

Verified Student

“I got full marks on my MATLAB DSP assignment! The filter design code was completely vectorized, the frequency response plots were exact, and the delivery was 8 hours before my deadline. Highly recommended!”

AS

Aditi Sharma

IIT Bombay • Signal Processing Coursework
Verified Student

“Our Simulink EV powertrain model had severe algebraic loop and solver errors. The MATLABSolutions team fixed the solver configuration in 4 hours and provided an annotated scope diagram. Lifesaver for my final year!”

JM

John M.

Monash University, Australia • Simulink Dynamic Model
Technical Knowledge Base

Latest MATLAB Guides & Tutorials

Explore deep-dive technical articles written by our engineering team to master complex MATLAB & Simulink topics.

MATLAB Guide 5 Min Read

Reinforcement Learning for Microgrid Energy Management in MATLAB & Simulink

Operating a modern microgrid is an ongoing balancing act. Between changing solar output, shifting wind speeds, volatile electricity pricing, and unpredictable consumer demand, a...

MATLAB Guide 5 Min Read

Physics-Informed Neural Networks (PINNs) for Microgrid Dynamics and Power Flow in MATLAB

Modern microgrids operate with low physical inertia, rapid inverter switching dynamics, and intermittent renewable power generation. Simulating these systems requir...