This page contains interactive live script examples developed based on the Control Tutorials for MATLAB and Simulink. These interactive tutorials help you learn how to use MATLAB for the analysis and design of automatic control systems. Click “Launch this example” to open and run the live script examples in your browser with MATLAB Online.

Introduction: System Modeling

The first step in the control design process is to develop appropriate mathematical models of the system to be controlled. These models may be derived either from physical laws or experimental data. In this example, we introduce the state-space and transfer function representations of dynamic systems. The interactive live script is then used to investigate two common examples of dynamics systems, a mass-spring damper system and an LRC circuit. For each of these systems, the effect of the systems’ parameters on their pole locations and resulting free response behavior is studied.  

Introduction: System Analysis 

Once appropriate mathematical models of a system have been obtained, either in differential equation or transfer function form, we may then analyze these models to predict how the system will respond in both the time and frequency domains. In this example, the live script demonstrates how a system’s time response is determined based on its natural dynamics and the forcing input. The live script also introduces the concept of frequency response by demonstrating how a system’s steady-state output changes for sinusoidal inputs of different frequencies. Finally, the live script illustrates how a second-order system’s damping ratio affects its Bode magnitude and phase plots.

Introduction: Root Locus Controller Design 

The root locus plot shows graphically all possible closed-loop pole locations of a feedback system as a parameter is varied. This is a useful tool for control system analysis and design. This live script introduces the concept of the root locus plot by generating an example figure one point at a time as a feedback system’s proportional gain is varied. This live script also demonstrates how a root locus plot can be employed to select a parameter based on some desired characteristics of the system’s closed-loop step response. 

Introduction: Frequency Domain Methods for Controller Design 

In this live script, the concept of frequency response is demonstrated by showing how a system’s steady-state output changes for inputs of different frequencies and how that information is plotted via a Bode diagram. This tutorial also demonstrates how we can use the open-loop frequency response of a system to predict its closed-loop time response behavior. This includes predicting a system’s speed, overshoot, and steady-state error, as well as its stability. The notion of stability margin is demonstrated using both the Bode diagram and the Nyquist diagram. 

Cruise Control: System Analysis  

In this example, a simple automotive cruise control system is modeled as a transfer function and its open-loop step response is investigated. The effect of the vehicle’s mass, drag profile, and drivetrain are explored using the interactive live script. Since the model employed has the form of a standard first-order transfer function, the system’s step response is interpreted in terms of the effect of the vehicle’s parameters on the transfer function model’s time constant and DC gain.

DC Motor Speed: System Analysis 

This live script investigates the dominant modes of a DC motor and how to generate a reduced-order model for the system. Specifically, an interactive live script illustrates how a motor parameter, such as the motor torque constant, affects the system’s poles and how the relative speeds of the poles impact the accuracy of a reduced-order model. Furthermore, the Reduce Order Model live editor task is demonstrated and the agreement between the original and reduced-order models are investigated for different types of inputs.  

DC Motor Position: PID Controller Design  

This live script illustrates how to design a PID controller for a motor position system subject to a constant disturbance load. The controller is designed to meet requirements on settling time, overshoot, and steady-state error of the closed-loop system’s step response. Through the interactive script, live controls are employed to demonstrate the effect of each of the three terms of the PID controller and to illustrate how they can be tuned to satisfy the given control specifications.  . 

Extras: Designing Lead and Lag Compensators 

This interactive page provides some insight into how to design lead and lag compensators by illustrating the effect of compensator parameters on a given system’s root locus plot and Bode diagram. For example, the live script demonstrates the effect of the addition of a lead compensator on the location of the asymptotes of a system’s root locus. Additionally, live controls are employed to illustrate the effect of varying the location of the lead and lag compensators’ poles and zeros on the resulting systems’ frequency response (Bode diagrams).