MATLAB Examples

Model objects can represent individual components of a control architecture, such as the plant, actuators, sensors, or controllers. You can connect model objects to build aggregate

Most PID tuning rules are based on the assumption that the plant can be approaximated by a first-order plus time delay system. This code explains why this assumption is valid and how to

A simulink model of Kalman filter organized as a feedback control system

Most PID tuning rules are based on first-order plus time delay assumption of the plant hence cannot ensure the best control performance. Using mordern optimization techniques, it is

The PID controller is the most widely used controller in various engineering systems. However, appropriately tuning a PID controller is not an easy task althrough it has only three

State Space MPC code.

Use Control System Toolbox™ to design a digital servo controller for a disk drive read/write head.

Design a compensator for a plant model defined by frequency response data (FRD) using Control System Designer.

Configure Control System Designer from the command line and how to create functions to customize the startup of a Control System Designer session.

Tune compensators for a feedback control system using Control System Designer.

Design and analyze a controller for multiple plant models using Control System Designer.

The design of a YAW DAMPER for a 747® aircraft using the classical control design features in Control System Toolbox™.

Perform Kalman filtering. Both a steady state filter and a time varying filter are designed and simulated below.

The design of a non-inverting feedback amplifier circuit using Control System Toolbox™. This design is built around the operational amplifier (op amp), a standard building block of

Estimate states of linear systems using time-varying Kalman filters in Simulink. You use the Kalman Filter block from the Control System Toolbox library to estimate the position and

The comparison of three DC motor control techniques for tracking setpoint commands and reducing sensitivity to load disturbances:

Design a MIMO LQG regulator to control the horizontal and vertical thickness of a steel beam in a hot steel rolling mill.

Design a compensator in an IMC structure for series chemical reactors, using Control System Designer. Model-based control systems are often used to track setpoints and reject load

Design a compensator for a plant with time delays using Control System Designer.

Use LQG synthesis to design a feedback controller for a disk drive read/write head using Control System Designer.

Estimate the states of a nonlinear system using an Unscented Kalman Filter in Simulink™. The example also illustrates how to develop an event-based Kalman Filter to update system

Perform nonlinear state estimation in Simulink™ for a system with multiple sensors operating at different sample rates. The Extended Kalman Filter block in Control System Toolbox™ is used

Use the unscented Kalman filter and particle filter algorithms for nonlinear state estimation for the van der Pol oscillator.

This case study illustrates Kalman filter design and simulation. Both steady-state and time-varying Kalman filters are considered.

Use command-line PID tuning options to reduce overshoot in reference tracking or to improve rejection of a disturbance at the plant input. Using the pidtune command, the example

Design a two-degree-of-freedom (2-DOF) PID controller at the command line. The example also compares the 2-DOF controller performance to the performance achieved with a 1-DOF PID

Linearize a plant model at a set of design points for tuning of a gain-scheduled controller. The example then uses the resulting linearized models to configure an slTuner interface for

Create and configure an slTuner interface for a Simulink® model. The slTuner interface parameterizes blocks in your model that you designate as tunable and allows you to tune them using

Tune the following control system to achieve a loop crossover frequency between 0.1 and 1 rad/s, using looptune.

Estimate the states of a discrete-time Van der Pol oscillator and compute state estimation errors and residuals for validating the estimation. The residuals are the output estimation

Design a computer hard-disk read/write head position controller using classical control design methods.

Use Simulink Control Design to tune a two-loop autopilot controlling the pitch rate and vertical acceleration of an airframe.

Use slTuner and systune to tune the current and velocity loops in a linear electric actuator with saturation limits.

Tune a controller for reducing vibrations in a flexible beam.

Interpret and validate tuning results from systune.

Use the Control System Tuner app to tune a MIMO, multiloop control system modeled in Simulink.

Gives a tour of available time-domain requirements for control system tuning with systune or looptune.

Uses systune to control an inverted pendulum on a cart.

Uses systune to design and tune a MIMO controller for a Diesel engine. The controller is tuned in discrete time for a single operating condition.

Use Control System Tuner to tune a control system when there are parameter variations in the plant. The control system of this example is an active suspension on a quarter-car model. The

Use systune or looptune to automatically tune control systems modeled in Simulink.

Leverage the Parallel Computing Toolbox™ to accelerate multi-start strategies for tuning fixed-structure control systems.

Use Control System Toolbox™ to tune a digital motion control system.

In this example, you learn how to use Control System Tuner app to design a controller for a nonlinear plant modeled in Simulink. You accomplish the following tasks:

Use slTuner and systune to tune the standard configuration of a longitudinal autopilot. We thank Professor D. Alazard from Institut Superieur de l'Aeronautique et de l'Espace for

Mitigate communication delays in a passive control system.

Uses systune to explore trade-offs between setpoint tracking and disturbance rejection when tuning PID controllers.

Use the Control System Tuner app to tune the current and velocity loops in a linear electric actuator with saturation limits.

Specify loop shapes and stability margins when tuning control systems with systune or looptune.

Use looptune to decouple the two main feedback loops in a distillation column.

Jointly tune the inner and outer loops of a cascade architecture with the systune command.

Tune a high-performance digital controller with bandwidth close to the sampling frequency.

Use slTuner and systune to tune a multiloop controller for a rotorcraft.

Gives a tour of available frequency-domain requirements for control system tuning with systune or looptune.

Use the commands for continuous/discrete, discrete/continuous, and discrete/discrete conversions.

The comparison of several techniques for discretizing a notch filter. While control system components are often designed in continuous time, they must generally be discretized for

Convert a discrete-time system to continuous time using d2c, and compares the results using two different interpolation methods.

Absorbing time delays into frequency response data can cause undesirable phase wrapping at high frequencies.

To reduce the order of a model by pole-zero cancelation at the command line, use minreal.

Convert a time delay in a discrete-time model to factors of 1/_z_.

Create a two-dimensional (2-D) array of transfer functions using for loops. One parameter of the transfer function varies in each dimension of the array.

Obtain the closed-loop response of a MIMO feedback loop in three different ways.

Compute a reduced-order approximation of a system when the system has unstable or near-unstable poles.

Compute a low-order approximation in two ways and compares the results. When you compute a low-order approximation by the balanced truncation method, you can either:

Convert a compensator from continuous to discrete time using several discretization methods, to identify a method that yields a good match in the frequency domain.

Insert multichannel analysis points in a generalized state-space model of a MIMO control system.

Build a block diagram and insert analysis points at locations of interest using the connect command. You can then use the analysis points to extract various system responses from the model.

Extract SISO control components from a 2-DOF PID controller in each of the feedforward, feedback, and filter configurations. The example compares the closed-loop systems in all

Query model characteristics such as stability, time domain, and number of inputs and outputs. You can use the techniques of this example on any type of dynamic system model.

Query the size of model arrays, including the number of inputs and outputs of the models in the array, and the array dimensions. It also shows how to query characteristics of the models in the

Focusing the energy-contribution calculation on a particular frequency region sometimes yields a good approximation to the dynamics of interest at a lower order than a reduction that

Sample a parametric model of a second-order filter across a grid of parameter values using sampleBlock.

Create a parametric model of the second-order filter:

Create a tunable model of the control system in the following illustration.

This model shows how to use an LTI System block to represent a MIMO linear system in Simulink®.

The LTISystemBlockSimulation model shows how to use an LTI System block to simulate the response of a SISO transfer function to a step input.

How choice of model type can affect numerical accuracy when interconnecting models.

Load an existing state-space ( docid:control_ref.f4-390421 ) model.

Upsample a system using both the d2d and upsample commands and compares the results of both to the original system.

Uses systune to generate smooth gain schedules for a three-loop autopilot.

Design and tune a gain-scheduled controller for a chemical reactor transitioning from low to high conversion rate. For background, see Seborg, D.E. et al., "Process Dynamics and Control",

This is Part 5 of the example series on design and tuning of the flight control system for the HL-20 vehicle. This part shows how to perform most of the design in MATLAB without interacting with

This is Part 3 of the example series on design and tuning of the flight control system for the HL-20 vehicle. This part shows how to tune a classic SISO architecture for controlling the roll,

This is Part 2 of the example series on design and tuning of the flight control system for the HL-20 vehicle. This part deals with closing the inner loops controlling the body angular rates.

This is Part 1 of a five-part example series on design and tuning of the flight control system for the HL-20 vehicle. This part deals with trimming and linearization of the airframe.

This is Part 4 of the example series on design and tuning of the flight control system for the HL-20 vehicle. This part shows how to tune a MIMO PI architecture for controlling the roll, pitch,

Proper scaling of state-space models can be critical for accuracy and provides an overview of automatic and manual rescaling tools.

Guidelines for building minimum-order models of LTI system interconnections.

Some best practices for working with LTI models.

High-multiplicity poles have high numerical sensitivity and can shift by significant amounts when switching model representation.

Why you should always use FEEDBACK to close feedback loops.

Revisit the optimal ITAE transfer function for step input using numerical optimization and digital computer.

Compute and plot the response of a state-space (ss) model to specified initial state values using initial.

Passive control is often part of the safety requirements in applications such as process control, tele-operation, human-machine interfaces, and system networks. A system is passive if it

In its simplest form, a conic sector is the 2-D region delimited by two lines, and .

Obtain a step-response plot and step-response data for a discrete-time dynamic system model. Obtaining time-domain responses of discrete-time models is the same as for continuous-time

Obtain numeric values of step response characteristics such as rise time, settling time, and overshoot using stepinfo. You can use similar techniques with lsiminfo to obtain

Obtain step and impulse response data, as well as step and impulse response plots, from a dynamic system model.

Examine the pole and zero locations of dynamic systems both graphically using pzplot and numerically using pole and zero .

Plot the frequency response and obtain frequency response data for a single-input, single-output (SISO) dynamic system model.

Obtain numeric values of several frequency-domain characteristics of a SISO dynamic system model, including the peak gain, dc gain, system bandwidth, and the frequencies at which the

Examine the frequency response of a multi-input, multi-output (MIMO) system in two ways: by computing the frequency response, and by computing the singular values.

Illustrates the properties of a series interconnection of passive systems.

Change the units of a Bode plot from rad/s to Hz.

Obtain impulse response data and plots for a multi-input, multi-output (MIMO) model using impulse . You can use the same techniques to obtain other types of time-domain responses of MIMO

Examine the sensitivity of a closed-loop control system to time delays within the system.

Compare the step responses of multiple models on a single plot using step . This example compares the step response of an uncontrolled plant to the closed-loop step response of the plant with

Construct a Linear Parameter Varying (LPV) representation of a system that exhibits multi-mode dynamics.

Model interconnections of LTI systems, from simple series and parallel connections to complex block diagrams.

How the Control System Toolbox™ lets you represent, manipulate, and analyze any LTI model with a finite number of delays. The delays can be at the system inputs or outputs, between specific

Create continuous-time linear models using the tf , zpk , ss , and frd commands.

Switch between the transfer function (TF), zero-pole-gain (ZPK), state-space (SS), and frequency response data (FRD) representations of LTI systems.

Access or edit parameter values and metadata in LTI objects.

Create discrete-time linear models using the tf , zpk , ss , and frd commands.

Examine the effect of stability margins on closed-loop response characteristics of a control system.

Use Control System Toolbox™ to analyze and design control systems with delays.

Analyze the time and frequency responses of common RLC circuits as a function of their physical parameters using Control System Toolbox™ functions.

Plot the time and frequency responses of SISO and MIMO linear systems.

Enforce absolute stability when a linear time-invariant system is in feedback interconnection with a static nonlinearity that belongs to a conic sector.

Compute various measures of passivity for linear time-invariant systems.

Illustrates the properties of a parallel interconnection of passive systems.

Illustrates the properties of a feedback interconnection of passive systems.

Reduce model order while preserving important dynamics using the Model Reducer app. This example illustrates the Balanced Truncation method, which eliminates states based on their

The limitations of PI control for processes with long dead time and illustrates the benefits of a control strategy called "Smith Predictor."

Design feedback and feedforward compensators to regulate the temperature of a chemical reactor through a heat exchanger.

Design a PI controller with good disturbance rejection performance using the PID Tuner tool. The example also shows how to design an ISA-PID controller for both good disturbance rejection

Design a cascade control loop with two PI controllers using the pidtune command.

Illustration of H-infinity loop-shaping with Robust Control Toolbox

Previously, we developed a back testing framework to calibrate a simple trading strategy to intraday data. In this demo we'll use extend the approach to three signals: MA, RSI, and Williams

The following example illustrate the change in peak time, settling time and percent overshoot as the poles of a 2nd order system move horizontaly, vertically and with fixed angle on the

This demo expands on the previous demo to incorporate a larger, intraday trading set (loaded from a database). More data implies more calculations, so we use Parallel Computing Toolbox to

Runs a market maker based upon bayesian updating of the probability of the bid or ask price.

This demo shows how functionality within Econometric Toolbox can be used to identify and calibrate a simple, intraday pairs trading strategy.

This demo is uses MATLAB to develop and test a simple trading strategy using an exponential moving average.

Illustrates the steps involved in integrating MATLAB and QuickFIX/J

Create a simple object in MATLAB® that will stream data at a specified frequency.

This demo is an introduction to using MATLAB to develop a simple trading strategy using an exponential moving average.

Two traders are in this simulation. The first is a momemntum trader. The second is a market maker. The momementum trader's goal is to make profit, the market maker's goal is to provide

Copyright 2010-2012, The MathWorks, Inc. All rights reserved.

Populates a table with market depth information as the prices update. Note that X_Trader is a 32-bit application and will only work with 32-bit Windows installations of MATLAB.

Show how to set up a listener and callback for a change in price. Note that X_Trader is a 32-bit application and will only work with 32-bit Windows installations of MATLAB.

Create an order and submit it. Note that X_Trader is a 32-bit application and will only work with 32-bit Windows installations of MATLAB.

This is a simple demonstration to highlight making use of .NET Assemblies directly in MATLAB.

These examples will show how to communicate with other hardware when running a MATLAB Function or Simulink Model directly on a desktop computer.

Hows to create a trajectory for waypoints in MATLAB with Splines. Trajectories are used to navigate between waypoints smoothly with respect to time.

Acquire and view acoustic data from a sound card using functionality from the Data Acquisition Toolbox.

There are two methods available to visualize point clouds. The first method plots a point cloud directly from showPointCloud and the second shows how to plot a point cloud using scatter3 and

Pack and unpack data using the provided packData and unpackData functions

This example shows how to generate code from packData and unpackData

Choose your country to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a location from the following list:

See all countries