easy-as-pie API to Simulink


Updated 10 Aug 2021

From GitHub

View License on GitHub

Editor's Note: This file was selected as MATLAB Central Pick of the Week

easy-as-pie API for Simulink models
slQuery is a "slickness-layer" ontop of the `find_system` and `get/set_param` API-functions and various related features of Simulink. It resulted from several inconveniences i had to deal with, while writing scripts that interact with and modify model structures.
Scripted manipulation of Simulink models had always required tons and tons of API-calls, awkward management of block handles vs. pathes, loops and subroutines for dealing with ports/lines or mux-/bus-signals. Dealing with Subsystem levels. In all this code, the main idea of what is being done cannot stand out clearly.
slQuery brings you two major tools that make scripted interaction with models a lot easier and cleaner.
1) slQuery is a query-language inspired by CSS/jQuery, XPath and regex that allows searching a loaded Simulink model for groups of blocks (called "situational patterns") that satisfy certain conditions and have certain relations to each other.
2) slQuery wraps arrays of Simulink block handles into lightweight "objects" that can be used to access block parameters and structural features in a syntactically pleasing way.

Cite As

Robert Rasche (2023). slQuery (, GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2018b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Component-Based Modeling in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!

Versions that use the GitHub default branch cannot be downloaded

Version Published Release Notes

* fix/add combinator "=" support for phyiscal signal routing
* fix `sel`: now excludes current system (only selected blocks inside
* support Two Way Conn blocks in "~>" and "=>" combinators
* better indexing subsasgn by reusing subsref code


* explicit text for hyperlink
* more special port chars in combinator portspecs
* `.sel`-method for instantly wrapping selected blocks in current system
* numeric subsref works for any shape result (X.LineHandles.Outport(1) gives all 1st lines)


add colon-operator for retrieving port- and line-handles of blocks
add basic support for Simscape physical connection modelling
add support for TargetLink properties in query-syntax


ability to reference block parameters of previous selectors
more flexible port/line retrieval with colon-operator


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.