Deep Learning with Simulink
Implement deep learning functionality in Simulink® models by using blocks from the Deep Neural Networks, Python Neural Networks, and Deep Learning Layers block libraries, included in the Deep Learning Toolbox™, or by using the Deep Learning Object Detector block from the Analysis & Enhancement block library included in the Computer Vision Toolbox™.
To generate a Simulink model that uses the Deep Learning Layers block library to represent a
network, use the exportNetworkToSimulink
function.
Some deep learning functionality in Simulink uses a MATLAB Function block that requires a supported
compiler. For most platforms, a default C compiler is supplied with the MATLAB® installation. When using C++ language, you must install a compatible
C++ compiler. To see a list of supported compilers, open Supported and Compatible Compilers, click the tab that corresponds to
your operating system, find the Simulink Product Family table,
and go to the For Model Referencing, Accelerator mode, Rapid Accelerator
mode, and MATLAB Function blocks column. If you have multiple
MATLAB-supported compilers installed on your system, you can change the
default compiler using the mex -setup
command. See Change Default Compiler.
Functions
exportNetworkToSimulink | Generate Simulink model that contains deep learning layer blocks that correspond to deep learning layer objects (Since R2024b) |
Blocks
Topics
Deep Learning Layer Blocks
- List of Deep Learning Layer Blocks
Discover all the deep learning layer blocks in Simulink. - Implement Unsupported Deep Learning Layer Blocks
TheexportNetworkToSimulink
function converts deep learning layer objects in adlnetwork
object to deep learning layer blocks in a Simulink model.
Images
- Classify Images in Simulink Using GoogLeNet
This example shows how to classify an image in Simulink® using theImage Classifier
block. - Acceleration for Simulink Deep Learning Models
Improve simulation speed with accelerator and rapid accelerator modes. - Lane and Vehicle Detection in Simulink Using Deep Learning
This example shows how to use deep convolutional neural networks inside a Simulink® model to perform lane and vehicle detection. - Classify ECG Signals in Simulink Using Deep Learning
This example shows how to use wavelet transforms and a deep learning network within a Simulink (R) model to classify ECG signals. - Classify Images in Simulink with Imported TensorFlow Network
Import a pretrained TensorFlow™ network usingimportTensorFlowNetwork
, and then use the Predict block for image classification in Simulink.
Sequences
- Predict and Update Network State in Simulink
This example shows how to predict responses for a trained recurrent neural network in Simulink® by using theStateful Predict
block. - Classify and Update Network State in Simulink
This example shows how to classify data for a trained recurrent neural network in Simulink® by using theStateful Classify
block. - Speech Command Recognition in Simulink
Detect the presence of speech commands in audio using a Simulink model. - Time Series Prediction in Simulink Using Deep Learning Network
This example shows how to use an LSTM deep learning network inside a Simulink® model to predict the remaining useful life (RUL) of an engine. - Simulate Calorie Burn Using Neural Network in Simulink
This example shows how to include a simple fully connected neural network in a Simulink® model that predicts calorie burn when given five time steps of sensor readings from a smart watch. - Battery State of Charge Estimation Using Deep Learning
Define requirements, prepare data, train deep learning networks, verify robustness, integrate networks into Simulink, and deploy models. (Since R2024b) - Physical System Modeling Using LSTM Network in Simulink
This example shows how to create a reduced order model (ROM) to replace a Simscape component in a Simulink® model by training a long short-term memory (LSTM) neural network. - Improve Performance of Deep Learning Simulations in Simulink
This example shows how to use code generation to improve the performance of deep learning simulations in Simulink®.
Reinforcement Learning
- Control Water Level in a Tank Using a DDPG Agent
Train a controller using reinforcement learning with a plant modeled in Simulink as the training environment. - Train DDPG Agent for Adaptive Cruise Control
Train a reinforcement learning agent for an adaptive cruise control application. - Train DQN Agent for Lane Keeping Assist Using Parallel Computing
Train a reinforcement learning agent for a lane keeping assist application. - Train DDPG Agent for Path-Following Control
Train a reinforcement learning agent for a lane following application.
Python Coexecution
- Classify Images Using TensorFlow Model Predict Block
Classify images using TensorFlow Model Predict block. - Classify Images Using ONNX Model Predict Block
Classify images using ONNX Model Predict block. - Classify Images Using PyTorch Model Predict Block
Classify images using PyTorch Model Predict block. - Predict Responses Using TensorFlow Model Predict Block
Predict Responses Using TensorFlow Model Predict block. - Predict Responses Using ONNX Model Predict Block
Predict Responses Using ONNX Model Predict block. - Predict Responses Using PyTorch Model Predict Block
Predict Responses Using PyTorch Model Predict block. - Predict Responses Using Custom Python Model in Simulink (Statistics and Machine Learning Toolbox)
This example shows how to use the Custom Python Model Predict (Statistics and Machine Learning Toolbox) block for prediction in Simulink®.
Code Generation
- Deep Learning Code Generation from Simulink Applications
Generate C/C++ and GPU code for deployment on desktop or embedded targets - Export Network to FMU
This example shows how to export a trained network as a Functional Mock-up Unit (FMU). (Since R2023b)