Control Tutorials for MATLAB and Simulink (2024)

Once appropriate mathematical models of a system have been obtained, either in state-space or transfer function form, we may then analyze these models to predict how the system will respond in both the time and frequency domains. To put this in context, control systems are often designed to improve stability, speed of response, steady-state error, or prevent oscillations. In this section, we will show how to determine these dynamic properties from the system models.

Key MATLAB commands used in this tutorial are: tf , ssdata , pole , eig , step , pzmap , bode , linearSystemAnalyzer

Run Live Script Version in MATLAB Online

Related Tutorial Links

  • Time Resp Activity
  • Freq Resp Activity

Related External Links

Contents

  • Time Response Overview
  • Frequency Response Overview
  • Stability
  • System Order
  • First-Order Systems
  • Second-Order Systems

Time Response Overview

The time response represents how the state of a dynamic system changes in time when subjected to a particular input. Since the models we have derived consist of differential equations, some integration must be performed in order to determine the time response of the system. For some simple systems, a closed-form analytical solution may be available. However, for most systems, especially nonlinear systems or those subject to complicated inputs, this integration must be carried out numerically. Fortunately, MATLAB provides many useful resources for calculating time responses for many types of inputs, as we shall see in the following sections.

The time response of a linear dynamic system consists of the sum of the transient response which depends on the initial conditions and the steady-state response which depends on the system input. These correspond to the hom*ogenous (free or zero input) and the particular solutions of the governing differential equations, respectively.

Frequency Response Overview

All the examples presented in this tutorial are modeled by linear constant coefficient differential equations and are thus linear time-invariant (LTI). LTI systems have the extremely important property that if the input to the system is sinusoidal, then the steady-state output will also be sinusoidal at the same frequency, but, in general, with different magnitude and phase. These magnitude and phase differences are a function of the frequency and comprise the frequency response of the system.

The frequency response of a system can be found from its transfer function in the following way: create a vector of frequencies (varying between zero or "DC" to infinity) and compute the value of the plant transfer function at those frequencies. If Control Tutorials for MATLAB and Simulink (1) is the open-loop transfer function of a system and Control Tutorials for MATLAB and Simulink (2) is the frequency vector, we then plot Control Tutorials for MATLAB and Simulink (3) versus Control Tutorials for MATLAB and Simulink (4). Since Control Tutorials for MATLAB and Simulink (5) is a complex number, we can plot both its magnitude and phase (the Bode Plot) or its position in the complex plane (the Nyquist Diagram). Both methods display the same information, but in different ways.

Stability

For our purposes, we will use the Bounded Input Bounded Output (BIBO) definition of stability which states that a system is stable if the output remains bounded for all bounded (finite) inputs. Practically, this means that the system will not "blow up" while in operation.

The transfer function representation is especially useful when analyzing system stability. If all poles of the transfer function (values of Control Tutorials for MATLAB and Simulink (6) for which the denominator equals zero) have negative real parts, then the system is stable. If any pole has a positive real part, then the system is unstable. If we view the poles on the complex s-plane, then all poles must be in the left-half plane (LHP) to ensure stability. If any pair of poles is on the imaginary axis, then the system is marginally stable and the system will tend to oscillate. A system with purely imaginary poles is not considered BIBO stable. For such a system, there will exist finite inputs that lead to an unbounded response. The poles of an LTI system model can easily be found in MATLAB using the pole command, an example of which is shown below:

s = tf('s');G = 1/(s^2+2*s+5)pole(G)
G = 1 ------------- s^2 + 2 s + 5 Continuous-time transfer function.ans = -1.0000 + 2.0000i -1.0000 - 2.0000i

Thus this system is stable since the real parts of the poles are both negative. The stability of a system may also be found from the state-space representation. In fact, the poles of the transfer function are the eigenvalues of the system matrix Control Tutorials for MATLAB and Simulink (7). We can use the eig command to calculate the eigenvalues using either the LTI system model directly, eig(G), or the system matrix as shown below.

[A,B,C,D] = ssdata(G);eig(A)
ans = -1.0000 + 2.0000i -1.0000 - 2.0000i

System Order

The order of a dynamic system is the order of the highest derivative of its governing differential equation. Equivalently, it is the highest power of Control Tutorials for MATLAB and Simulink (8) in the denominator of its transfer function. The important properties of first-, second-, and higher-order systems will be reviewed in this section.

First-Order Systems

First-order systems are the simplest dynamic systems to analyze. Some common examples include mass-damper systems and RC circuits.

The general form of the first-order differential equation is as follows

(1)Control Tutorials for MATLAB and Simulink (9)

The form of a first-order transfer function is

(2)Control Tutorials for MATLAB and Simulink (10)

where the parameters Control Tutorials for MATLAB and Simulink (11) and Control Tutorials for MATLAB and Simulink (12) completely define the character of the first-order system.

DC Gain

The DC gain, Control Tutorials for MATLAB and Simulink (13), is the ratio of the magnitude of the steady-state step response to the magnitude of the step input. For stable transfer functions, the Final Value Theorem demonstrates that the DC gain is the value of the transfer function evaluated at Control Tutorials for MATLAB and Simulink (14) = 0. For first-order systems of the forms shown, the DC gain is Control Tutorials for MATLAB and Simulink (15).

Time Constant

The time constant of a first-order system is Control Tutorials for MATLAB and Simulink (16) which is equal to the time it takes for the system's response to reach 63% of its steady-state value for a step input (from zero initial conditions) or to decrease to 37% of the initial value for a system's free response. More generally, it represents the time scale for which the dynamics of the system are significant.

Poles/Zeros

First-order systems have a single real pole, in this case at Control Tutorials for MATLAB and Simulink (17). Therefore, the system is stable if Control Tutorials for MATLAB and Simulink (18) is positive and unstable if Control Tutorials for MATLAB and Simulink (19) is negative. Standard first-order system have no zeros.

Step Response

We can calculate the system time response to a step input of magnitude Control Tutorials for MATLAB and Simulink (20) using the following MATLAB commands:

k_dc = 5;Tc = 10;u = 2;s = tf('s');G = k_dc/(Tc*s+1)step(u*G)
G = 5 -------- 10 s + 1 Continuous-time transfer function.

Control Tutorials for MATLAB and Simulink (21)

Note: MATLAB also provides a powerful graphical user interface for analyzing LTI systems which can be accessed using the syntax linearSystemAnalyzer('step',G).

If you right-click on the step response graph and select Characteristics, you can choose to have several system metrics overlaid on the response: peak response, settling time, rise time, and steady-state.

Settling Time

The settling time, Control Tutorials for MATLAB and Simulink (22), is the time required for the system output to fall within a certain percentage (i.e. 2%) of the steady-state value for a step input. The settling times for a first-order system for the most common tolerances are provided in the table below. Note that the tighter the tolerance, the longer the system response takes to settle to within this band, as expected.

10%5%2%1%
Ts=2.3/a=2.3TcTs=3/a=3TcTs=3.9/a=3.9TcTs=4.6/a=4.6Tc

Rise Time

The rise time, Control Tutorials for MATLAB and Simulink (23), is the time required for the system output to rise from some lower level x% to some higher level y% of the final steady-state value. For first-order systems, the typical range is 10% - 90%.

Bode Plots

Bode diagrams show the magnitude and phase of a system's frequency response, Control Tutorials for MATLAB and Simulink (24), plotted with respect to frequency Control Tutorials for MATLAB and Simulink (25). We can generate the Bode plot of a system Control Tutorials for MATLAB and Simulink (26) in MATLAB using the syntax bode(G) as shown below.

bode(G)

Control Tutorials for MATLAB and Simulink (27)

Again the same results could be obtained using the Linear System Analyzer GUI, linearSystemAnalyzer('bode',G).

Bode plots employ a logarithmic frequency scale so that a larger range of frequencies are visible. Also, the magnitude is represented using the logarithmic decibel unit (dB) defined as:

(3)Control Tutorials for MATLAB and Simulink (28)

As with the frequency axis, the decibel scale allows us to view a much larger range of magnitudes on a single plot. Also, as we shall see in subsequent tutorials, when components and controllers are placed in series, the transfer function of the overall system is the product of the individual transfer functions. Using the dB scale, the magnitude plot of the overall system is simply the sum of the magnitude plots of the individual transfer functions. The phase plot of the overall system is also just the sum of the individual phase plots.

The low frequency magnitude of the first-order Bode plot is Control Tutorials for MATLAB and Simulink (29). The magnitude plot has a bend at the frequency equal to the absolute value of the pole (ie. Control Tutorials for MATLAB and Simulink (30)), and then decreases 20 dB for every factor of ten increase in frequency (slope = -20 dB/decade). The phase plot is asymptotic to 0 degrees at low frequencies, and asymptotic to -90 degrees at high frequencies. Between frequency 0.1a and 10a, the phase changes by approximately -45 degrees for every factor of ten increase in frequency (-45 degrees/decade).

We will see in the Frequency Methods for Controller Design Section how to use Bode plots to calculate closed-loop stability and performance of feedback systems.

Second-Order Systems

Second-order systems are commonly encountered in practice, and are the simplest type of dynamic system to exhibit oscillations. Examples include mass-spring-damper systems and RLC circuits. In fact, many true higher-order systems may be approximated as second-order in order to facilitate analysis.

The canonical form of the second-order differential equation is as follows

(4)Control Tutorials for MATLAB and Simulink (31)

The canonical second-order transfer function has the following form, in which it has two poles and no zeros.

(5)Control Tutorials for MATLAB and Simulink (32)

The parameters Control Tutorials for MATLAB and Simulink (33), Control Tutorials for MATLAB and Simulink (34), and Control Tutorials for MATLAB and Simulink (35) characterize the behavior of a canonical second-order system.

DC Gain

The DC gain, Control Tutorials for MATLAB and Simulink (36), again is the ratio of the magnitude of the steady-state step response to the magnitude of the step input, and for stable systems it is the value of the transfer function when Control Tutorials for MATLAB and Simulink (37). For the forms given,

(6)Control Tutorials for MATLAB and Simulink (38)

Damping Ratio

The damping ratio Control Tutorials for MATLAB and Simulink (39) is a dimensionless quantity charaterizing the rate at which an oscillation in the system's response decays due to effects such as viscous friction or electrical resistance. From the above definitions,

(7)Control Tutorials for MATLAB and Simulink (40)

Natural Frequency

The natural frequency Control Tutorials for MATLAB and Simulink (41) is the frequency (in rad/s) that the system will oscillate at when there is no damping, Control Tutorials for MATLAB and Simulink (42).

(8)Control Tutorials for MATLAB and Simulink (43)

Poles/Zeros

The canonical second-order transfer function has two poles at:

(9)Control Tutorials for MATLAB and Simulink (44)

Underdamped Systems

If Control Tutorials for MATLAB and Simulink (45), then the system is underdamped. In this case, both poles are complex-valued with negative real parts; therefore, the system is stable but oscillates while approaching the steady-state value. Specifically, the natural response oscillates with the damped natural frequency, Control Tutorials for MATLAB and Simulink (46) (in rad/sec).

k_dc = 1;w_n = 10;zeta = 0.2;s = tf('s');G1 = k_dc*w_n^2/(s^2 + 2*zeta*w_n*s + w_n^2);pzmap(G1)axis([-3 1 -15 15])

Control Tutorials for MATLAB and Simulink (47)

step(G1)axis([0 3 0 2])

Control Tutorials for MATLAB and Simulink (48)

Settling Time

The settling time, Control Tutorials for MATLAB and Simulink (49), is the time required for the system ouput to fall within a certain percentage of the steady-state value for a step input. For a canonical second-order, underdamped system, the settling time can be approximated by the following equation:

(10)Control Tutorials for MATLAB and Simulink (50)

The settling times for the most common tolerances are presented in the following table:

10%5%2%1%
Ts=2.3/(zeta*w_n)Ts=3/(zeta*w_n)Ts=3.9/(zeta*w_n)Ts=4.6/(zeta*w_n)

Percent Overshoot

The percent overshoot is the percent by which a system's step response exceeds its final steady-state value. For a second-order underdamped system, the percent overshoot Control Tutorials for MATLAB and Simulink (51) is directly related to the damping ratio by the following equation. Here, Control Tutorials for MATLAB and Simulink (52) is a decimal number where 1 corresponds to 100% overshoot.

(11)Control Tutorials for MATLAB and Simulink (53)

For second-order underdamped systems, the 1% settling time, Control Tutorials for MATLAB and Simulink (54), 10-90% rise time, Control Tutorials for MATLAB and Simulink (55), and percent overshoot, Control Tutorials for MATLAB and Simulink (56), are related to the damping ratio and natural frequency as shown below.

(12)Control Tutorials for MATLAB and Simulink (57)

(13)Control Tutorials for MATLAB and Simulink (58)

(14)Control Tutorials for MATLAB and Simulink (59)

Overdamped Systems

If Control Tutorials for MATLAB and Simulink (60), then the system is overdamped. Both poles are real and negative; therefore, the system is stable and does not oscillate. The step response and a pole-zero map of an overdamped system are calculated below:

zeta = 1.2;G2 = k_dc*w_n^2/(s^2 + 2*zeta*w_n*s + w_n^2);pzmap(G2)axis([-20 1 -1 1])

Control Tutorials for MATLAB and Simulink (61)

step(G2)axis([0 1.5 0 1.5])

Control Tutorials for MATLAB and Simulink (62)

Critically-Damped Systems

If Control Tutorials for MATLAB and Simulink (63), then the system is critically damped. Both poles are real and have the same magnitude, Control Tutorials for MATLAB and Simulink (64). For a canonical second-order system, the quickest settling time is achieved when the system is critically damped. Now change the value of the damping ratio to 1, and re-plot the step response and pole-zero map.

zeta = 1;G3 = k_dc*w_n^2/(s^2 + 2*zeta*w_n*s + w_n^2);pzmap(G3)axis([-11 1 -1 1])

Control Tutorials for MATLAB and Simulink (65)

step(G3)axis([0 1.5 0 1.5])

Control Tutorials for MATLAB and Simulink (66)

Undamped Systems

If Control Tutorials for MATLAB and Simulink (67), then the system is undamped. In this case, the poles are purely imaginary; therefore, the system is marginally stable and the step response oscillates indefinitely.

zeta = 0;G4 = k_dc*w_n^2/(s^2 + 2*zeta*w_n*s + w_n^2);pzmap(G4)axis([-1 1 -15 15])

Control Tutorials for MATLAB and Simulink (68)

step(G4)axis([0 5 -0.5 2.5])

Control Tutorials for MATLAB and Simulink (69)

Bode Plot

We show the Bode magnitude and phase plots for all damping conditions of a second-order system below:

bode(G1,G2,G3,G4)legend('underdamped: zeta < 1','overdamped: zeta > 1','critically-damped: zeta = 1','undamped: zeta = 0')

Control Tutorials for MATLAB and Simulink (70)

The magnitude of the bode plot of a second-order system drops off at -40 dB per decade in the limit, while the relative phase changes from 0 to -180 degrees. For underdamped systems, we also see a resonant peak near the natural frequency, Control Tutorials for MATLAB and Simulink (71) = 10 rad/s. The size and sharpness of the peak depends on the damping in the system, and is charaterized by the quality factor, or Q-Factor, defined below. The Q-factor is an important property in signal processing.

(15)Control Tutorials for MATLAB and Simulink (72)


Published with MATLAB® 9.2

Control Tutorials for MATLAB and Simulink (2024)

FAQs

How to use MATLAB with Simulink? ›

Create a Simulink Model
  1. In the MATLAB® Home tab, click the Simulink button.
  2. Click Blank Model, and then Create Model. ...
  3. On the Simulation tab, click Library Browser.
  4. In the Library Browser: ...
  5. Make the following block-to-block connections: ...
  6. Double-click the Transfer Fcn block. ...
  7. Double-click the Signal Generator block.

How is MATLAB used in control systems? ›

Using MATLAB and Simulink control systems products, you can: Model linear and nonlinear plant dynamics using basic models, system identification, or automatic parameter estimation. Trim, linearize, and compute frequency response for nonlinear Simulink models.

What is the control model in Simulink? ›

Simulink® Control Design™ lets you design and analyze control systems modeled in Simulink. You can automatically tune arbitrary SISO and MIMO control architectures, including PID controllers.

Why use Simulink over MATLAB? ›

You can also create custom blocks using MATLAB functions or other Simulink models. Simulink blocks provide a visual representation of your system, which can help you to verify its logic and behavior. On the other hand, MATLAB code requires you to write and edit text commands, which can be more complex and error-prone.

Is MATLAB Simulink hard to learn? ›

MATLAB is designed for the way you think and the work you do, so learning is accessible whether you are a novice or an expert. The Help Center is always available to guide you with robust documentation, community answers, and how-to videos. Additionally, online interactive training is a great way to get started.

How do you integrate MATLAB code into Simulink? ›

You can integrate your MATLAB code into Simulink using the MATLAB Function block and MATLAB System block. Use MATLAB Function block to integrate simple functions. Use the MATLAB System block to integrate code that requires state dynamics, large streaming data interface, and interaction with the Simulink engine.

What is MATLAB control system toolbox? ›

Control System Toolbox™ provides algorithms and apps for systematically analyzing, designing, and tuning linear control systems. You can specify your system as a transfer function, state-space, zero-pole-gain, or frequency-response model.

What is MATLAB most useful for? ›

MATLAB is a programming and numeric computing platform used by millions of engineers and scientists to analyze data, develop algorithms, and create models.

Why is MATLAB so widely used? ›

Algorithm Development: MATLAB is widely used for developing and implementing algorithms. It provides a convenient environment for prototyping, testing, and refining algorithms before deploying them in real-world applications.

How to make a controller in Simulink? ›

This is accomplished by first clicking on the Add Blocks button, and then selecting the PID Controller block from the resulting window as shown below. Next click the OK button. Note that controllers represented by other types of blocks (Transfer Function, State Space, etc.)

How to understand Simulink model? ›

In Simulink, systems are drawn on screen as block diagrams. Many elements of block diagrams are available, such as transfer functions, summing junctions, etc., as well as virtual input and output devices such as function generators and oscilloscopes.

How to design a controller in MATLAB? ›

To design a controller, first select the controller sample time and horizons, and specify any required constraints. For more information, see Choose Sample Time and Horizons and Specify Constraints. You can then adjust the controller weights to achieve your desired performance.

Is Simulink faster than MATLAB? ›

Direct link to this question

I tried implementing several algorithms with both simulink and pure matlab code. On all occasions, the simulink version was faster.

Why is MATLAB Simulink so slow? ›

(2) Check the sufficiency of RAM and disk space available on your computer. Running out of memory can lead to slowdowns. (3) Check network Issues. If Simulink is connected to a network license server, network issues could impact performance.

Do I need MATLAB for Simulink? ›

Simulink is for MATLAB Users

Use MATLAB and Simulink together to combine the power of textual and graphical programming in one environment. Apply your MATLAB knowledge to: Optimize parameters. Create new blocks.

How to run Simulink simulation from MATLAB? ›

Sim with Model Name

If you have a Simulink model that simulates using the Run button, the quickest and simplest way to simulate it from MATLAB is probably to call the sim command and pass it the model name. For example, I have a model saved as suspension. slx.

Can I add Simulink to MATLAB? ›

Download and install MATLAB, Simulink, and accompanying toolboxes and blocksets on a personal computer. Add toolboxes, products, apps, support packages, and other add-ons to an existing installation of MATLAB. Add products, update your current MATLAB installation, and update your license.

How to use Simulink output in MATLAB? ›

On the Modeling tab, under Settings, click Model Settings. Then, in the Configuration Parameters dialog box, select Data Import/Export and select Single simulation output. You run a set of simulations using the Multiple Simulations pane. You simulate the model programmatically using one or more Simulink.

Top Articles
A MID-AMERICA NIGHT’S DREAM! USAC MIDGETS HEAD TO THE GREAT PLAINS JULY 9-13 - USAC Racing
Home Run Derby 2024: Top Storylines to Track for Every Participant
Fighter Torso Ornament Kit
Netronline Taxes
Le Blanc Los Cabos - Los Cabos – Le Blanc Spa Resort Adults-Only All Inclusive
What happened to Lori Petty? What is she doing today? Wiki
Ymca Sammamish Class Schedule
Unitedhealthcare Hwp
Devotion Showtimes Near Mjr Universal Grand Cinema 16
Crossed Eyes (Strabismus): Symptoms, Causes, and Diagnosis
7543460065
Dityship
Gina's Pizza Port Charlotte Fl
Mission Impossible 7 Showtimes Near Regal Bridgeport Village
Cnnfn.com Markets
Industry Talk: Im Gespräch mit den Machern von Magicseaweed
Uc Santa Cruz Events
Craigslist Blackshear Ga
Buy PoE 2 Chaos Orbs - Cheap Orbs For Sale | Epiccarry
Condogames Xyz Discord
Nashville Predators Wiki
Iu Spring Break 2024
Roll Out Gutter Extensions Lowe's
Alfie Liebel
Gina Wilson All Things Algebra Unit 2 Homework 8
Panolian Batesville Ms Obituaries 2022
Pearson Correlation Coefficient
3Movierulz
Enduring Word John 15
Martins Point Patient Portal
Housing Intranet Unt
ATM, 3813 N Woodlawn Blvd, Wichita, KS 67220, US - MapQuest
Chapaeva Age
Xfinity Outage Map Lacey Wa
1400 Kg To Lb
Missouri State Highway Patrol Will Utilize Acadis to Improve Curriculum and Testing Management
Chuze Fitness La Verne Reviews
Delaware judge sets Twitter, Elon Musk trial for October
3302577704
Marcus Roberts 1040 Answers
Cheetah Pitbull For Sale
B.C. lightkeepers' jobs in jeopardy as coast guard plans to automate 2 stations
Engr 2300 Osu
Luvsquad-Links
Torrid Rn Number Lookup
11 Best Hotels in Cologne (Köln), Germany in 2024 - My Germany Vacation
Gli italiani buttano sempre più cibo, quasi 7 etti a settimana (a testa)
Florida Lottery Powerball Double Play
Go Nutrients Intestinal Edge Reviews
Craigslist Charles Town West Virginia
Makemkv Key April 2023
Competitive Comparison
Latest Posts
Article information

Author: Clemencia Bogisich Ret

Last Updated:

Views: 5265

Rating: 5 / 5 (60 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Clemencia Bogisich Ret

Birthday: 2001-07-17

Address: Suite 794 53887 Geri Spring, West Cristentown, KY 54855

Phone: +5934435460663

Job: Central Hospitality Director

Hobby: Yoga, Electronics, Rafting, Lockpicking, Inline skating, Puzzles, scrapbook

Introduction: My name is Clemencia Bogisich Ret, I am a super, outstanding, graceful, friendly, vast, comfortable, agreeable person who loves writing and wants to share my knowledge and understanding with you.