This week, I’m introducing a set of two examples applied utilizing the workflow described on this weblog publish sequence.
This week’s examples are bigger and extra advanced than the examples beforehand launched on this sequence. Hopefully, they are going to assist higher illustrate some great benefits of this workflow.
Overview
When you obtain and unzip the File Change submission, you can find the next:
workflow Undertaking
openSimulinkExample.m
This instance simulates the dynamics of a car suspension and could be configured to simulate a number of kinds of suspensions with totally different levels of freedom. Here’s a diagram for the 2 levels of freedom longitudinal configuration:
openSimscapeExample.m
This script opens the instance saved within the folder SimscapeExample. I applied this instance by combining three examples from Simscape Driveline:
This instance means that you can simulate the acceleration of a car with various kinds of hybrid drivetrains.
I made a decision to incorporate this instance for a few causes. First, I discover that this workflow suits notably properly with Simscape bodily elements. Second, this illustrates that the identical workflow core functionalities, the slPart class and the system configurator app, work for various initiatives.
Every challenge accommodates a reside script (walkthroughSL.mlx or walkthrough_SSC.mlx) to information you thru the steps of use the mannequin.
Mannequin and Knowledge Hierarchy
One of many foremost takeaways from this instance is that every slPart is manufactured from a Simulink Subsystem and a MATLAB class. When assembled in a simulation, this ends in a hierarchy of MATLAB courses comparable to the hierarchy of Subsystems within the mannequin.
Whenever you open the primary mannequin within the challenge, you will note that it accommodates one Subsystem that takes as parameter an object named vehicleObject
In MATLAB, outline this variable by instantiating one of many courses within the +car package deal:
Here’s what the hierarchy of Subsystems appears like within the mannequin:
and the corresponding hierarchy of MATLAB courses:
Within the mannequin, you could find Variant Subsystems:
In MATLAB, tab-completion lists the identical obtainable variants, and you may select the energetic one by assigning it to the corresponding property of the mother or father object:
You too can tweak parameter values. For instance, the mass of the car in Simulink
could be modified in MATLAB via the car object:
See the walkthrough.mlx reside script in every challenge for extra instance MATLAB code interacting with the mannequin via the vehicleObject variable.
Configuring the Simulation Utilizing the MATLAB App
To get began with app, I’m providing you with two choices, relying in your preferences:
- Dowload and watch this 5 minutes video the place I stroll you thru how the app works
- Use the next picture as a “cheat sheet” to get began: