slQuery - the "easy-as-pie" API to Simulink
slQuery is a "slickness-layer" ontop of the
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.
slQuery brings you two major tools that make scripted interaction with models very easy and
slQueryis a query language inspired by CSS/jQuery, XPath and regex that allows searching a Simulink model for groups of blocks that satisfy certain conditions and relations to each other.
slQuerywraps arrays of Simulink block handles into lightweight "proxy objects" that can be used to access block parameters and structural features in a syntactically pleasing way.
Have a look: This small example script shows how to interact with a model using
acts on the two plain blocks given on the left side and step-by-step transforms them to become
the Simulink logo on the right.
But this only the beginning! For a detailed description of what
slQuery allows you to do, go
to the documentation and reference pages section.
slQuery is implemented as a crazily compact single class
file, that you just put onto the
MATLAB search path somewhere. You can download and install the script in your local scripts
folder using the following command.
websave(fullfile(uigetdir, '/slQuery.m'), 'https://raw.githubusercontent.com/arinar/slQuery/master/slQuery.m')
This will give you all the
To also have the documentation and tests available locally, clone this repositiory or download
the .zip and then use the
pathtool command to add it to the MATLAB search path.
Bugs or Contributions
Report bugs or missing features of
slQuery as well as ideas or code via the project page on
Or contact me directly via robert with a circle-a then raschhour followed by the dotcom.
slQuery and TargetLink
At my job, I've been working with the dSPACE TargetLink production code
generator a lot.
is to a great extent the result of me recognizing and refining best practices and code patterns
for an efficient automation of tedious modelling tasks. Scripting is often the only feasible
way to handle systematic changes to our code generation basis models. The TargetLink block data
API is in my opinion just as not-slick as the Simulink API and so, more expressive means of
interacting with this data were needed as well. Therefore TargetLink has a special place in
Both the query language and proxy object magic do support access and manipulation of the
TargetLink block data. This access is made possible via the special
parameters in the query and
.tl.〈tab〉.〈prop〉 subscript syntax of
the wrapper objects.
slQuery's baby sister project
ddQuery provides a
similar tooling for the TargetLink Data Dictionary, which is oftentimes even more useful in
Robert Rasche (2023). slQuery (https://github.com/arinar/slQuery), GitHub. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
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
* line-connect features
* line-connect features
* fix/add combinator "=" support for phyiscal signal routing
* explicit text for hyperlink
add colon-operator for retrieving port- and line-handles of blocks
ability to reference block parameters of previous selectors