top of page

A Beginner's Guide to Frequency Analysis for Your Simulink Model

Author: Pat Gipper

Measuring frequency response waveforms on a Simulink model


When designing control systems, you target specific goals of achieving a response bandwidth while still maintaining gain and phase margins. In the early stages, the system is simulated prior to the availability of hardware. Simulink® from MathWorks has served us well in this purpose for many years. We have created a Simulink frequency response tool for measuring the bandwidth of complex Simulink simulations. Array of Engineers has made one of these tools available as a Community App via MathWorks’ File Exchange. Simply follow this link to download:

Frequency Response Analyzer - File Exchange - MATLAB Central (

The Frequency Response Analyzer (FRA) app places a sine wave signal onto an injection point within your simulation. The FRA has two measurement channels: Channel 1 and Channel 2. These two channels can be any signals that you desire from your simulation. The FRA will determine the gain and phase shift of Channel 2 versus Channel 1 at the frequency of the injected sine wave. The frequency of the injected sine wave is then swept over a range that you define for your system measurement.

This piece will step you through an introduction on how to use the Simulink frequency response tool with a simple example.

Getting Started

Once you have downloaded and installed the Simulink “Frequency Response Analyzer” (FRA) application, it can be opened from the Matlab APPS tab.

FRA has three tabs; Analyzer, Help and Console.

User inputs occur in the Analyzer window, the Help window provides instructions via a simple example to get you familiar with FRA, and the Console window contains operational outputs such as error messages.

When FRA first starts in the Analyzer window you will see some empty text boxes, two position switches, and check boxes as shown in the figure below.

We highly recommend that you examine the Help tab. That tab is a quick summary of this document's lengthier instructions, which are always available when using FRA.

Make A Simple Second Order Model

The first thing you will do is create a simple second order model as shown below and save it to the current folder directory. The “From Workspace” element will be used by FRA to inject sine waves of a specified frequency and amplitude into your simulation. The “To Workspace” elements pass output signals from your simulation to the FRA for measurement.

This second order model has a natural frequency of 33.3 rad/sec and a damping ratio of 0.4. Pretty simple!

It is extremely important that the “To Workspace” use the variable “cint” for the sample time as shown because the FRA will modify the sample rate using that variable name. It is also mandatory that the Save format use Array as opposed to Structure or Timeseries formats that won’t work with FRA.

Anyone who can identify what ancient simulation tool used “cint” for the communication interval can claim the experience from way back prize 😊

Define Workspace Variables

These are some workspace variables required by FRA to do its task.

cint - The communication interval is contained in the “To Workspace” signals and its value is modified by the FRA to get the required number of data points per cycle, defined on the Analyzer window (). For this example, define it as follows:

cint = 0.001;% communication interval [sec]

fra_fvec - This is an array of frequencies with units of Hertz that you are asking the FRA to measure. I usually start at the highest frequency and sweep down to lower frequencies to see the results sooner. For this example, define it as follows:

% Array of frequencies for analysis sweep [Hz]

fra_fvec =[80;70;60;50;40;30;20;15;10;9;8;7;6;5;4;3;2;1];

fra_ncyc - This is an array defining how many cycles to simulate for each frequency in fra_fvec. The number of cycles for a given frequency should be chosen large enough according to the settling time of the system being simulated. This ensures that the FRA measurement is accurate. For this example, define it as follows:

% Array of number of cycles for each frequency

fra_ncyc =[20;20;20;20;20;10;10;10;10;9;8;7;6;5;4;3;2;2];

[ti,ui] - The signal names assigned the “To Workspace” block in the simulation. These signals need to be defined in the workspace. Their values will be changed by the FRA. Usually defined as follows:

ti = [0;100];% time array [seconds]

ui = [0;0];% stimulus array [simulation dependent units]

Once you have completed defining these variables, your MATLAB Workspace should look like this: