Find Blocks in Linearization Results Matching Specific Criteria
When you linearize a Simulink® model, you can find blocks in your linearization result that match specific criteria using the Linearization Advisor. You can specify search criteria to find blocks that can:
Potentially cause linearization issues in your model, if your model does not linearize as expected. For more information on identifying and fixing linearization issues using the Linearization Advisor, see Identify and Fix Common Linearization Issues.
Help you gain insight into your model linearization, even if the model has linearized as expected.
You can also query the Linearization Advisor at the command line using the find
function. For an example, see Troubleshoot Linearization Results at Command Line.
Searching the linearization results requires linearization diagnostic information. To collect this information, you must enable the Linearization Advisor before linearizing your model.
To enable the Linearization Advisor, in the Model Linearizer, on the Linear Analysis tab, select Linearization Advisor.
When you select this option and linearize your model, the software opens an Advisor tab for troubleshooting your linearization results. You can then find blocks of interest in the linearization results by running queries with the Linearization Advisor.
After finding blocks of interest, you can examine the individual block linearizations using the linearization diagnostic information. For more information, see Block Linearization Troubleshooting.
Run Built-In Queries
The Linearization Advisor provides a set of built-in queries for searching your linearization results. These queries are useful for finding blocks that are potentially causing linearization issues. To run one of these queries, on the Advisor tab, in the Queries section, click the query.
Built-In Query | Find Blocks That... |
---|---|
Linearization Advice | Are potentially problematic for linearization. This query is performed by default when the Advisor tab opens. |
Diagnostics on Path | Are on the linearization path and that have diagnostic messages
regarding their linearization. This query is a subset of the
Linearization Advice query. |
Substitutions on Path | Are on the linearization path and have a custom block
linearization specified. This query is a subset of the
Linearization Advice query. |
Zero I/O Pair on Path | Are on the linearization path and have at least one input/output pair that linearizes to zero. |
All Blocks on Path | Are on the linearization path; that is, blocks where at least one linearization input is connected to at least one linearization output through the block. |
Create and Run Queries
The linearization advisor also provides a set of simple queries for searching your model. You can run these queries on their own or use them to create compound queries.
Simple Query | Find Blocks That... |
---|---|
All Blocks | Are in the linearized model. |
Linearized to Zero | Linearize to zero. |
Block Substituted | Have a custom block linearization specified. |
On Linearization Path | Are on the linearization path. |
Contributes to Linearization | Numerically contribute to the model linearization result. |
Exact | Are linearized using their defined exact linearization. |
Perturbation | Are linearized using numerical perturbation. |
Has Diagnostics | Have diagnostic messages regarding their linearization. |
'BlockType' Blocks | Are of a specified type. |
Has 'Nu' Inputs | Have a specified number of inputs. |
Has 'Nx' States | Have a specified number of states. |
Has 'Ny' Outputs | Have a specified number of outputs. |
Has 'Ts' Sample Time | Have a specified sample time. |
Has Zero I/O Pair | Have at least one input/output pair that linearizes to zero. |
To run a simple query, in Model Linearizer, on the Advisor tab, click New Query.
In the Query Builder dialog box, configure the query. For example, create a query for finding all blocks that numerically contribute to the linearization result.
In the Query Name field, specify the name for the query as
Contributes
.In the drop-down list, select
Contributes to Linearization
.If you select any of the following queries, specify the corresponding search parameter.
Query Search Parameter 'BlockType' Blocks
Block Type — This parameter corresponds to the blocktype
property of the block. For more information, seelinqueryIsBlockType
.Has 'Nu' Inputs
Inputs — Specify a positive integer. Has 'Nx' States
States — Specify a positive integer. Has 'Ny' Outputs
Outputs — Specify a positive integer. Has 'Ts' Sample Time
Sample Time — Specify a nonzero scalar. To find continuous-time blocks, specify 0
.To create and run the query, click Run Query. The software runs the query and, on the Advisor tab, displays the list of blocks that contribute to the model linearization.
The app adds the query to the Queries section.
To remove a custom query from the gallery, select the query under Remove Query.
You can also create compound queries by logically combining existing queries using And, Or, and Not logical operations. You can create a compound query using simple queries, built-in queries, or other compound queries.
To create a compound query, in the Query Builder dialog box, configure the query using multiple search criteria. For example, create a query to find all discrete-time blocks that are on the linearization path.
In the Query Name field, specify the name for the query as
Discrete on Path
.To find blocks on the linearization path, in the drop-down list, select
On Linearization Path
.To add another search criterion, click Add to Query. The software adds a second row to the search criteria. By default, the search criteria are combined using an And operation.
(optional) To remove a search criterion, in the corresponding row, click .
To find discrete-time blocks, perform the following steps.
Add a search criterion to find continuous-time blocks. In the second row, in the drop-down list, select
Has 'Ts' Sample Time
. Keep the default Sample Time of0
.To find discrete-time blocks, in the second row, select Not.
To run the query, click Run Query.
Each time you create a custom query, the software adds it to the drop-down list of
search criteria in the Query Builder dialog box. You can then use your custom
queries to create more complex queries. For example, to find discrete-time blocks on
the linearization path that are linearized using numerical perturbation, create a
query that combines the Discrete on Path
custom query
with the Perturbed
simple query using an
And operation.