Unifying MATLAB and Simulink Example

Version 1.0.0 (1.91 MB) by Guy Rouleau
Example complementing the blog post series “Unifying MATLAB and Simulink: A User Story Part” on the blog “Guy on Simulink”
103 Downloads
Updated 21 Jun 2022

Unifying MATLAB and Simulink Example

Open in MATLAB Online

View <File Exchange Title> on File Exchange

This repository contains two examples accompanying the series of blog posts titled Unifying MATLAB and Simulink: A User Story on Guy on Simulink.

The workflow illustrated in this example systematically combines a MATLAB class and a Simulink Subsystem into a fundamental unit called Simulink Part.

Unifying MATLAB and Simulink

The MATLAB class contains the data needed by the Simulink model along with methods. It can also include methods to pre- and post-process the data needed by and produced by the model.

Parameterizing Simulink with MATLAB objects

Once the Simulink Part is placed in a model, the corresponding MATLAB object knows where it is being used, thanks to callbacks defined in a library of template blocks.

Simulink Parts can be assembled in a hierarchical manner, where a Simulink Part can become a property (child) of another Simulink Part. You can imagine the analogy with a garage or workshop with mechanical parts on shelves. Basic components like gears, nuts, bolts, springs and dampers can be assembled in systems like transmissions and suspensions, which can then be assembled into vehicles.

A hierarchhy of Simulink Parts

The model and corresponding MATLAB object can be configured using MATLAB code. See the walkthrough.mxl live scripts included in the project for examples:

Live script describing how to configure the model programmatically

The model can also be configured using an app:

System Confiurator App

Copyright 2022 The MathWorks, Inc.

Setup

To Run:

  1. Execute openSimulinkExample.m or openSimscapeExample.m to open the corresponding project.
  2. Each project contains a file "walkthrough.slx", see this file to get started

Additional information about the repository can be found on Guy on Simulink:

MathWorks Products (http://www.mathworks.com)

Requires MATLAB release R2022a or newer

Optional Products:

Getting Started

To get started, execute openSimulinkExample.m or openSimscapeExample.m to open the corresponding project. Each project contains a live script walkthrough.mlx with details on how to get started.

License

The license for Unifying MATLAB and Simulink Example is available in the License.txt file in this GitHub repository.

Community Support

MATLAB Central

Cite As

Guy Rouleau (2024). Unifying MATLAB and Simulink Example (https://github.com/guirlo/Unifying-MATLAB-and-Simulink-Example/releases/tag/v1.0.0), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2022a
Compatible with R2022a and later releases
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

SimscapeExample/+battery

SimscapeExample/+body

SimscapeExample/+drivetrain

SimscapeExample/+drivetrain/+generator

SimscapeExample/+drivetrain/+motor

SimscapeExample/+engine

SimscapeExample/+vehicle

SimulinkExample/+body

SimulinkExample/+damper

SimulinkExample/+spring

SimulinkExample/+suspension

SimulinkExample/+vehicle

workflow

SimscapeExample

SimscapeExample/+drivetrain/+generator/mdl

SimscapeExample/+drivetrain/+motor/mdl

SimulinkExample

SimulinkExample/+suspension/mdl

workflow

Version Published Release Notes
1.0.0

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.