Simulink® model elements as objects
Version 1.0.1 (133 KB) by
Ken Xu
Represent Simulink® model elements as MATLAB® objects, with enhanced search and batch operation capabilities.
Simulink® Model Elements as MATLAB® Objects
Introduction
The slelement package is a working prototype for the ideas of
1. Representing Simulink model elements as MATLAB objects, usable with Simulink APIs (get_param, add_block, etc)
2. Searching model elements with an extensible sementic
3. Doing batch operations on model elements
Examples
Complete API cheatsheet, and live demos are under the doc directory. Below is just a sample of what you can do.
Making objects out of identifiers
Use the "makeElement" helper to create model element objects.
mdl = slelement.makeElement('modelname')
blk = slelement.makeElement('modelname/blockname')
Finding elements and performing batch operations
Find all the ports connected to outport blocks:
element_selector = ...
Ports('porttype','outport') > ... % all output ports connected to
( Blocks('blocktype','Outport') | ... % outport blocks'
Ports('porttype','inport') ); % inports
outport_inputs = mdl.select(element_selector);
Turn on port value labels for all of them:
outport_inputs.set('ShowValueLabel','on');
Copyright 2024 The MathWorks, Inc.
Cite As
Ken Xu (2024). Simulink® model elements as objects (https://www.mathworks.com/matlabcentral/fileexchange/160606-simulink-model-elements-as-objects), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2024a
Compatible with R2017b and later releases
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.