MATLAB Examples

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

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

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

Load flight data and estimate G forces during the flight.

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

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.

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

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

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.

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 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).

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)

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

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

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

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

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

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.

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

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

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

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.

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

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

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

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

State Space MPC code.

Pack and unpack data using the provided packData and unpackData functions

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.

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

This example was authored by the MathWorks community.

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

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

Use anfis command for nonlinear dynamical system identification.

Implement a fuzzy inference system for nonlinear PID control using a 2-D Lookup Table block.

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

This model shows how to implement a fuzzy inference system (FIS) in a Simulink® model.

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

Do chaotic time series prediction using ANFIS.

Use Fuzzy C-Means clustering for Iris dataset.

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™.

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

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

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

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

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.

You can generate code for a Fuzzy Logic Controller block using Simulink® Coder™. For more information on generating code, see docid:rtw_doccenter.code-generation.

You can generate Structured Text for a Fuzzy Logic Controller block using Simulink® PLC Coder™. For more information on generating Structured Text, see

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

Once you have implemented a fuzzy inference system using Fuzzy Logic Designer, using Neuro-Fuzzy Designer, or at the command line, you can simulate the system in Simulink.

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

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.

This document explains how to use the DMC Simulink block.

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

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. For both command-line and Simulink® simulations, you specify updated input and output constraints at each control interval.

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.

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.

Control a double integrator plant under input saturation in Simulink®.

Design model predictive controller with one measured output, one manipulated variable, one measured disturbance, and one unmeasured disturbance in a typical workflow.

Design a model predictive controller by first from linearizing a nonlinear plant in Simulink® .

Design a model predictive controller for a multi-input multi-output nonlinear plant. The plant has 3 manipulated variables and 2 measured outputs.

Design a model predictive controller with non-zero nominal values.

Uses a model predictive controller (MPC) to control an inverted pendulum on a cart.

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

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

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

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

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.

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

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

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

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®

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

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

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.

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

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 H_\infty 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

Use Robust Control Toolbox™ to analyze and quantify the robustness of feedback control systems. It also provides insight into the connection with mu analysis and the mussv function.

Use the Robust Control Toolbox™ command ucover to model a family of LTI responses as an uncertain system. This command is useful to fit an uncertain model to a set of frequency responses

Illustrates the pitfalls of using frequency gridding to compute robustness margins for systems with only real uncertain parameters. It presents a safer approach along with ways to

Use uncertain objects in Robust Control Toolbox™ to model uncertain systems and to automate robustness calculations using the robustness analysis tools.

Use Robust Control Toolbox™ to build uncertain state-space models and analyze the robustness of feedback control systems with uncertain elements.

Use Robust Control Toolbox™ to analyze the robustness of an uncertain system with only real parametric uncertainty. You compute the stability margins for a rigid body transport aircraft

Make a Simulink® block linearize to an uncertain variable at the command line. To learn how to specify an uncertain block linearization using the Simulink model editor, see

You create uncertain matrices ( docid:robust_ref.f10-328118 objects) by creating uncertain parameters and using them to build matrices. You can then use uncertain matrices to build

You decompose an uncertain model into a fixed certain part and normalized uncertain part using the docid:robust_ref.f10-120643 command. To see how this command works, create a 2-by-2

Create a periodic random Gaussian input signal using idinput.

Estimate the unknown parameters of a continuous-time model.

Access the estimation report.

Estimate model parameters using linear and nonlinear grey-box modeling.

Represent the structure of the following continuous-time model:

Grey-box modeling of the dynamics of an industrial robot arm. The robot arm is described by a nonlinear three-mass flexible model according to Figure 1. This model is idealized in the sense

The modeling of a measured signal. We analyze the current signal from the R-phase when a 400 kV three-phase transformer is energized. The measurements were performed by Sydkraft AB in

Estimate a transfer function from frequency response data. You use Simulink® Control Design™ to collect frequency response data from a Simulink model and the tfest command to estimate a

Develop and analyze simple models from a real laboratory process data. We start with a small description of the process, learn how to import the data to the toolbox and preprocess/condition

Nonlinear grey-box modeling of vehicle dynamics. Many new vehicle features (like Electronic Stability Programs (ESP), indirect Tire Pressure Monitoring Systems (TPMS), road-tire

Nonlinear black-box modeling of the dynamic behavior of a magneto-rheological fluid damper. It shows how to create Nonlinear ARX and Hammerstein-Wiener models of the damper using

Estimate a transfer function from measured signal data.

The grey-box modeling of a large and complex nonlinear system. The purpose is to show the ability to use the IDNLGREY model to estimate a large number of parameters (16) in a system having many

Linear model identification of a glass tube manufacturing process. The experiments and the data are discussed in:

Computation of bending modes of a flexible wing aircraft. The vibration response of the wing is collected at multiple points along its span. The data is used to identify a dynamic model of the

Create a multi-experiment, time-domain data set by merging only the accurate data segments and ignoring the rest.

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

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

Estimate parameters in user-defined model structures. Such structures are specified by IDGREY (linear state-space) or IDNLGREY (nonlinear state-space) models. We shall investigate

Illustrates how models simulated in Simulink® can be identified using System Identification Toolbox™. The example describes how to deal with continuous-time systems and delays, as well

Manage data and model objects available in the System Identification Toolbox™. System identification is about building models from data. A data set is characterized by several pieces of

Obtain linear approximations of a complex, nonlinear system by means of linear model identification. The approach is based on selection of an input signal that excites the system. A linear

The benefits of regularization for identification of linear and nonlinear models.

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:

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.