Documentation

linqueryHasSampleTime

Query object for finding blocks with specified sample time

Description

linqueryHasSampleTime creates a custom query object for finding all the blocks in a linearization result that have a specified sample time.

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 Linear Analysis Tool. For more information on finding specific blocks in linearization results, see Find Blocks in Linearization Results Matching Specific Criteria.

Creation

Syntax

query = linqueryHasSampleTime(SampleTime)

Description

example

query = linqueryHasSampleTime(SampleTime) creates a query object for finding all the blocks in a LinearizationAdvisor object that have a sample time equal to SampleTime.

Input Arguments

expand all

Block sample time, specified as a nonnegative scalar. Specify SampleTime in the time units of the linearized model.

To find continuous-time blocks, specify SampleTime as 0.

Properties

expand all

Number of block outputs, specified as a nonnegative integer equal to SampleTime.

Query type, specified as a character vector of the form 'Has <T> Sample Time', where <T> is equal to Ts.

Query description, specified as a character vector of the form 'Blocks with <T> Sample Time', where <T> is equal to Ts. You can add your own description to the query object using this property.

Usage

After creating a linqueryHasSampleTime query object, you can:

  • Find all the blocks in a LinearizationAdvisor object that have a specified sample time by using the linqueryHasSampleTime query directly with the find command.

  • Create a CompoundQuery object by logically combining the linqueryHasSampleTime query with other query objects.

Object Functions

findFind blocks in linearization results that match specific criteria

Examples

expand all

Load the Simulink model.

mdl = 'scdmrate';
load_system(mdl)

Linearize the model and obtain the LinearizationAdvisor object.

opts = linearizeOptions('StoreAdvisor',true);
io(1) = linio('scdmrate/Constant',1,'input');
io(2) = linio('scdmrate/sysTs2',1,'openoutput');
[linsys,linop,info] = linearize(mdl,io,opts);
advisor = info.Advisor;

Create query object and find all the linearized blocks with a sample time of 0.1 seconds.

qTs = linqueryHasSampleTime(0.01);
advTs = find(advisor,qTs)
advTs = 
  LinearizationAdvisor with properties:

               Model: 'scdmrate'
      OperatingPoint: [1×1 opcond.OperatingPoint]
    BlockDiagnostics: [1×1 linearize.advisor.BlockDiagnostic]
           QueryType: 'Has 0.01 Sample Time'

Description: Blocks with 0.01 Sample Time 

Check the 'BlockDiagnostic' property to examine the block diagnostics. 
Use the advise or find command to further prune the block diagnostics.

Load the Simulink model.

mdl = 'scdmrate';
load_system(mdl)

Linearize the model and obtain the LinearizationAdvisor object.

opts = linearizeOptions('StoreAdvisor',true);
io = getlinio(mdl);
[sys,op,info] = linearize(mdl,io,opts);
advisor = info.Advisor;

Create query object, and find all linearized blocks with continuous-time linearizations.

qCont = linqueryHasSampleTime(0);
advCont = find(advisor,qCont)
advCont = 
  LinearizationAdvisor with properties:

               Model: 'scdmrate'
      OperatingPoint: [1x1 opcond.OperatingPoint]
    BlockDiagnostics: [1x5 linearize.advisor.BlockDiagnostic]
           QueryType: 'Has 0 Sample Time'

Alternative Functionality

App

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

Introduced in R2017b

Was this topic helpful?