Main Content

CompoundQuery

Complex query object for finding specific blocks in linearization results

Description

CompoundQuery query object for finding all the blocks in a LinearizationAdvisor object that have a specified number of inputs.

When you linearize a Simulink® model, you can create a LinearizationAdvisor object that contains diagnostic information about individual block linearizations. To find block linearizations that satisfy specific criteria, you can use the find function with custom query objects. Alternatively, you can analyze linearization diagnostics using the Linearization Advisor in the Model Linearizer. For more information on finding specific blocks in linearization results, see Find Blocks in Linearization Results Matching Specific Criteria.

Creation

To create a CompoundQuery object, combine other query objects using AND (&), OR (|), and NOT (~) logical operations. For example, see:

Properties

expand all

Query type, specified as a character vector. By default, QueryType is constructed using logical operators and the QueryType properties of the queries used to create the compound query. For example, suppose that you create a compound query for finding all SISO blocks:

qIn = linqueryHasInputs(1);
qOut = linqueryHasOutputs(1);
qSISO = qIn & qOut;

Then, QueryType is '(Has 1 Inputs & Has 1 Outputs)'.

You can modify QueryType for your application. For example:

qSISO.QueryType = 'SISO Blocks';

Query description, specified as '' by default. You can add your own description to the query object using this property.

Object Functions

findFind blocks in linearization results that match specific criteria

Examples

collapse all

Create a CompundQuery object for finding any blocks that linearize to zero or any non-SISO blocks that are on the linearization path.

Create a query object for finding all non-SISO blocks.

qNotSISO = ~(linqueryHasOutputs(1) & linqueryHasInputs(1));

Create a query object for finding all blocks on the linearization path.

qOnPath = linqueryIsOnPath;

Create a query object for finding all blocks that linearize to zero.

qZero = linqueryIsZero;

To create a query for finding any blocks that linearize to zero or any non-SISO blocks that are on the linearization path, combine the other query objects.

query = (qNotSISO & qOnPath) | qZero
query = 
  CompoundQuery with properties:

      QueryType: '((~((Has 1 Outputs & Has 1 Inputs)) & On Linearization Path) | Linearized to Zero)'
    Description: ''

Load the Simulink model.

mdl = 'scdspeed';
load_system(mdl)

Linearize the model and obtain the LinearizationAdvisor object.

opts = linearizeOptions('StoreAdvisor',true);
io(1) = linio('scdspeed/throttle (degrees)',1,'input');
io(2) = linio('scdspeed/rad//s to rpm',1,'output');
[sys,op,info] = linearize(mdl,io,opts);
advisor = info.Advisor;

Create compound query object for finding all blocks with one input and one output.

qSISO = linqueryHasInputs(1) & linqueryHasOutputs(1);

Find all SISO blocks using compound query object.

advSISO = find(advisor,qSISO)
advSISO = 
  LinearizationAdvisor with properties:

               Model: 'scdspeed'
      OperatingPoint: [1x1 opcond.OperatingPoint]
    BlockDiagnostics: [1x10 linearize.advisor.BlockDiagnostic]
           QueryType: '(Has 1 Inputs & Has 1 Outputs)'

Alternative Functionality

App

You can also create custom queries for finding specific blocks in linearization results using the Linearization Advisor in the Model Linearizer. For more information, see Find Blocks in Linearization Results Matching Specific Criteria.

Version History

Introduced in R2017b