MATLAB Examples

Implement a steady, viscous flow through an insulated, constant-area duct using the Aerospace Toolbox™ software. This flow is also called Fanno line flow.

Create a flight animation for a trajectory using a FlightGear Animation object.

Visualize aircraft takeoff and chase helicopter with the virtual reality animation object. In this example, you can use the Aero.VirtualRealityAnimation object to set up a virtual

Use the Aerospace Toolbox™ functions to determine heat transfer and mass flow rate in a ramjet combustion chamber.

Visualize simulated versus actual flight trajectories with the animation object (Aero.Animation) while showing some of the animation object functionality. In this example, you can use

Use the method of characteristics and Prandtl-Meyer flow theory to solve a problem in supersonic flow involving expansions. Solve for the flow field downstream of the exit of a supersonic

Load flight data and estimate G forces during the flight.

Visualize contour plots of the calculated values for the Earth's magnetic field using World Magnetic Model 2015 (WMM-2015) overlaid on maps of the Earth. The Mapping Toolbox™ software is

Calculate the required compressor power in a supersonic wind tunnel.

Bring United States Air Force (USAF) Digital DATCOM files into the MATLAB® environment using the Aerospace Toolbox™ software.

Perform glide calculations for a Cessna 172 following Example 9.1 in reference 1 using the Aerospace Toolbox™ software.

Calculate the Earth's Geoid height using the EGM96 Geopotential Model of the Aerospace Toolbox™ software. It also shows how to visualize the results with contour maps overlaid on maps of the

Use the planetary ephemerides and a Earth Centered Inertial to Earth Centered Earth Fixed (ECI to ECEF) transformation to perform celestial navigation of a marine vessel.

This demo illustrates the computation of a solution family to the boundary value problem

This demonstration uses the 'ab' example of AUTO to demonstrate the use of the Dynamical Systems Toolbox in the 07P (AUTO) mode. Input and output files are similar to the ones used in AUTO.

Examine the zonal harmonic, spherical and 1984 World Geodetic System (WGS84) gravity models for latitudes from +/- 90 degrees at the surface of the Earth.

This demonstration uses the 'ab' example of AUTO to demonstrate the use of Matlab functions with the Dynamical Systems Toolbox in the DST mode.

This demo illustrates the computation of a solution family to the equation

The equations, that model a two-compartment enzyme system (Kernevez,1980), are given by

This demo illustrates the computation of a solution family and its bifurcating families for a discrete dynamical system. Also illustrated is the continuation of Naimark-Sacker (or Hopf)

This demonstration uses the 'ab' example of AUTO to demonstrate the use of Simulink with the Dynamical Systems Toolbox in the DST mode.

This demo illustrates the computation of stationary solutions, Hopf bifurcations and periodic solutions in the reaction (Doedel & Heinemann, 1983).

Estimate the analemma of the Sun. The analemma is the curve that represents the variation of the angular offset of the Sun from its mean position on the celestial sphere relative to a specific

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

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

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

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

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

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

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

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

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

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

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.

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

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

Improve the frequency-domain accuracy of a system with a time delay that is a fractional multiple of the sample time.

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

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

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

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

At the command-line, use balred to compute a reduced-order approximation of a model.

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

Create a one-dimensional array of transfer functions using the stack command. One parameter of the transfer function varies from model to model in the array. You can use such an array to

Use the command line features of anfis on a chaotic time-series prediction example.

How FCM clustering works using quasi-random two-dimensional data.

Apply the genfis function to model the relationship between the number of automobile trips generated from an area and the area's demographics. Demographic and trip data are from 100 traffic

To illustrate the value of fuzzy logic, examine both linear and fuzzy approaches to the following problem:

This example was authored by the MathWorks community.

Adjust the amount of fuzzy overlap when performing fuzzy c-means clustering.

Do chaotic time series prediction using ANFIS.

Use a fuzzy system to model the inverse kinematics in a two-joint robotic arm.

Use Fuzzy C-Means clustering for Iris dataset.

Perform fuzzy c-means clustering on 2-dimensional data.

Predict of fuel consumption (miles per gallon) for automobiles, using data from previously recorded observations.

Display five defuzzification methods supported in the Fuzzy Logic Toolbox™.

Use anfis command for nonlinear dynamical system identification.

Use a 2-D Lookup Table block to implement a fuzzy inference system for nonlinear fuzzy PID control.

Use Fuzzy Logic Toolbox™ software for image processing. Specifically, this example shows how to detect edges in an image.

Use a fuzzy-logic inference system in a Simulink® model.

Do adaptive nonlinear noise cancellation using the anfis and genfis commands.

Use subtractive clustering to model traffic patterns in an area based on the area's demographics.

Display 11 membership functions supported in the Fuzzy Logic Toolbox™.

You can construct a Mamdani fuzzy inference system (FIS) at the MATLAB® command line. This method is an alternative to interactively designing your FIS using docid:fuzzy.bu9027w.

Dynamic Matrix Control (DMC) was the first Model Predictive Control (MPC) algorithm introduced in early 1980s. Nowadays, DMC is available in almost all commercial industrial distributed

This document explains how to use the setup function and online controller returned by ssmpcsetup.

This document explains how to use the DMC Simulink block.

Obtain a linear model of a plant using a MATLAB script.

How create and test a model predictive controller from the command line.

Identify a plant model at the command line. For information on identifying models using the System Identification app, see docid:ident_gs.bqs6ip8.

Obtain an LTI representation of an unconstrained MPC controller using docid:mpc_ref.f2-23723. You can use this to analyze the frequency response and performance of the controller.

Analyze a model predictive controller using docid:mpc_ref.f2-8236. This function computes the closed-loop, steady-state gain for each output when a sustained, 1-unit disturbance is

Design a model predictive controller at the command line using an identified plant model.

Design an MPC controller for a blending process using custom input and output constraints.

Vary the weights on outputs, inputs, and ECR slack variable for soft constraints in real-time.

Design a model predictive controller with look-ahead (previewing) on reference and measured disturbance trajectories.

Vary input and output saturation limits in real-time control.

Obtain bumpless transfer when switching model predictive controller from manual to automatic operation or vice versa.

Use the "qp.status" outport of the MPC Controller block in Simulink® to detect controller failures in real time.

Simulate the closed-loop response of an MPC controller with a custom quadratic programming (QP) solver in Simulink®.

Use measurable plant states in MPC control at run time.

Use the "optimal cost" outport of the MPC Controller block to switch between multiple model predictive controllers whose outputs are restricted to discrete values.

Control an unstable aircraft with saturating actuators.

Control a thermo-mechanical pulping (TMP) plant with a model predictive controller.

Design a model predictive controller in MATLAB for a high-fidelity distillation tower model built in Aspen Plus Dynamics®. The controller performance is then verified through

Use constraints on a combination of inputs and outputs to control a nonlinear blending process.

Design a model predictive controller for a DC servomechanism under voltage and shaft torque constraints.

Explores more in-depth interaction with the Gazebo® Simulator from MATLAB®. Topics include creating simple models, adding links and joints to models, connecting models together, and

Demonstrates how to control a robot to follow a desired path using a Robot Simulator. The example uses the Pure Pursuit path following controller to drive a simulated robot along a

The primary mechanism for ROS nodes to exchange data is to send and receive messages. Messages are transmitted on a topic and each topic has a unique name in the ROS network. If a node wants to

Set up the Gazebo® simulator engine. This example prepares you for further exploration with Gazebo and also for exploration with a simulated TurtleBot®.

Interact with the Gazebo® Simulator from MATLAB®. It shows how to pause the Gazebo simulation, read the physics properties, and retrieve information about objects in the Gazebo world.

Demonstrates how to compute an obstacle free path between two locations on a given map using the Probabilistic Roadmap (PRM) path planner. PRM path planner constructs a roadmap in the free

Messages are the primary container for exchanging data in ROS. Topics (see docid:robotics_examples.example-ROSPublishAndSubscribeExample) and services (see

A rosbag or bag is a file format in ROS for storing message data. These bags are often created by subscribing to one or more ROS topics, and storing the received message data in an efficient file

Explores MATLAB® control of the Gazebo® Simulator.

Introduces the TurtleBot® platform and the ways in which MATLAB® users can interact with it. Specifically, the code in this example demonstrates how to publish messages to the TurtleBot

Keyboard control of the TurtleBot® through the use of the ExampleHelperTurtleBotCommunicator class. The instructions describe how to set up the object and how to start the keyboard

A ROS network consists of a single ROS master and multiple ROS nodes. The ROS master facilitates the communication in the ROS network by keeping track of all active ROS entities. Every node

Some commonly used ROS messages store data in a format that requires some transformation before it can be used for further processing. MATLAB® can help you by formatting these specialized

Robot Operating System (ROS) is a communication interface that enables different parts of a robot system to discover, send, and receive data. MATLAB® support for ROS is a library of

Demonstrates an implementation of the VFH+ obstacle avoidance algorithm with the TurtleBot®. The use of timers is explored to expose their power in autonomous algorithms.

Connect to a TurtleBot® using the MATLAB® ROS interface. You can use this interface to connect to a wide range of ROS-supported hardware from MATLAB. If you are using a TurtleBot in Gazebo®

In this example, you explore autonomous behavior that incorporates the Kinect® camera. This algorithm involves the TurtleBot® looking for a blue ball and then staying at a fixed distance

ROS supports two main communication mechanisms: topics and services. Topics have publishers and subscribers and are used for sending and receiving messages (see

Illustrates a collection of ways to apply forces and torques to models in the Gazebo® simulator. First, application of torques is examined in three distinct ways using doors for

Helps you to explore basic autonomy with the TurtleBot®. The described behavior drives the robot forward and changes its direction when there is an obstacle. You will subscribe to the laser

The tf system in ROS keeps track of multiple coordinate frames and maintains the relationship between them in a tree structure. tf is distributed, so that the information about all

Explores how to add and retrieve parameters on the ROS parameter server. The parameter server usually runs on the same device that launches the ROS master. The parameters are accessible

Generate and build a standalone ROS node from a Simulink model.

An uncertain parameter has a name (used to identify it within an uncertain system with many uncertain parameters) and a nominal value. Being uncertain, it also has variability, described in

You can create and analyze uncertain state-space models made up of uncertain state-space matrices. In this example, create a MIMO system with parametric uncertainty and analyze it for

In most cases, the multiplicative error model reduction method bstmr tends to bound the relative error between the original and reduced-order models across the frequency range of

Given a system G in LTI form, the following commands reduce the system to any desired order you specify. The judgment call is based on its Hankel singular values.

Create uncertain real parameters, modify properties such as range of uncertainty, and sample uncertain parameters.

When sampling an ultidyn element or an uncertain object that contains a ultidyn element, the result is always a state-space (ss) object. The property SampleStateDimension of the ultidyn

The command usample randomly samples the uncertain system at a specified number of points. Randomly sample an uncertain system at 20 points in its modeled uncertainty range. This gives a

In many cases, a model's -axis poles are important to keep after model reduction, e.g., rigid body dynamics of a flexible structure plant or integrators of a controller. A unique routine,

You can create a 1-by-1 (scalar) positive-real uncertain linear dynamics element, whose frequency response always has real part greater than -0.5. Set the SampleStateDimension property

It is possible to form interconnections of uss objects. A common example is to form the feedback interconnection of a given controller with an uncertain plant.

Construct a generalized state-space (genss) model of a control system that has both tunable and uncertain parameters. You can use systune to tune the tunable parameters of such a model to

Perform mixed mu-synthesis with the dksyn command in the Robust Control Toolbox™. Here dksyn is used to design a robust controller for a two mass-spring-damper system with uncertainty in

Use Robust Control Toolbox™ to design a multi-input, multi-output controller by shaping the gain of an open-loop response across frequency. This technique is applied to controlling the

Use Robust Control Toolbox™ to design a robust controller (using D-K iteration) and to do robustness analysis on a process control problem. In our example, the plant is a simple two-tank

Use Robust Control Toolbox™ function ncfsyn to improve the stability robustness of a closed-loop system while approximately maintaining the high-gain and low-gain characteristics of

Use the Robust Control Toolbox™ commands usample, ucover and dksyn to design a robust controller with standard performance objectives. It can serve as a template for more complex robust

Use mu-analysis and synthesis tools in the Robust Control Toolbox™. It describes the design of a robust controller for the lateral-directional axis of an aircraft during powered approach

Uses the Robust Control Toolbox™ commands ucover and dksyn to design a high-performance controller for a family of unstable plants.

Uses the hinfstruct command to tune a fixed-structure controller subject to constraints.

Use Robust Control Toolbox™ to design a robust controller for an active suspension system.

Use Simulink® blocks and helper functions provided by Robust Control Toolbox™ to specify and analyze uncertain systems in Simulink and how to use these tools to perform Monte Carlo

Use loopmargin to analyze the closed-loop robustness of Simulink models with specified loop-breaking points.

Compute uncertain linearizations using Robust Control Toolbox™ and Simulink® Control Design™. There are two convenient workflows offered depending on how Simulink is used. The

Estimate a model that is parameterized by poles, zeros, and gains. The example requires Control System Toolbox™ software.

Estimate an initial model and refine it using pem.

Create a periodic random Gaussian input signal using idinput.

Simulate a continuous-time state-space model using a random binary input u and a sample time of 0.1 s.

Use nlarx to estimate a nonlinear ARX model for measured input/output data.

Generate output data by simulating a model using an input signal created using idinput.

Estimate the parameters of a first-order process model:

Estimate the unknown parameters of a discrete-time model.

Validate an estimated model by comparing the simulated model output with measured data.

Estimate Autoregressive Integrated Moving Average or ARIMA models.

Create input data and a model, and then use the data and the model to simulate output data.

Estimate the unknown parameters of a continuous-time model.

Estimate Hammerstein-Wiener models using linear OE models.

Estimate a process model with fixed parameters.

Estimate transfer function models with I/O delays.

How the software evaluates the simulated output by first computing the output of the input and output nonlinearity estimators.

Refine models for which you have initial parameter guesses.

Create a multiexperiment iddata object by merging iddata objects, where each contains data from a single experiment or is a multiexperiment data set.

Compare multiple estimated models using the estimation report.

Estimate a transfer function model when the structure of the expected model is known and apply constraints to the numerator and denominator coefficients.

Identify a transfer function to fit a given frequency response data (FRD) containing additional phase roll off induced by input delay.

Estimate a transfer function model with unknown transport delays and apply an upper bound on the unknown transport delays.

Access the estimation report.

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