Hauptinhalt

find

R2026b

Get element or collection of elements from Simulink.SimulationData.Dataset object

Description

[dsOut,idx]=find(dsIn,prop,val,...) returns a Simulink.SimulationData.Dataset object containing the elements in the Dataset object dsIn that match one or more property type and value pairs specified by prop and val. The function also returns the indices of those elements in the Dataset object dsIn.

example

[dsOut,idx]=find(dsIn,prop,val,logical,...prop,val,...) applies the logical operator logical to connect multiple property and value pairs. You can combine multiple logical operators.

example

[dsOut,idx]=find(dsIn,'-regexp',prop,val,...) matches elements using regular expressions as if the value of the property is passed to the regexp function as

regexp(element.prop,val)
The find function applies regular expression matching to the prop and val arguments that appear after -regexp. If the find function contains no -regexp argument, then the function matches elements as if the value of the property is passed as

isequal(element.prop,val)

example

Examples

Input Arguments

collapse all

Dataset object in which to search for matching elements, specified as a Simulink.SimulationData.Dataset object.

Type of property to search, specified as a string or character vector.

Each element in a Dataset object is an object. The type of each object depends on the data it contains. An element must have the property type defined by prop to be included in the Dataset object returned by the find function. For example, you can find Simulink.SimulationData.Signal object elements in a Dataset object using any of the properties of a Signal object:

  • Name — Name of element

  • PropagatedName — Propagated signal name

  • BlockPath — Block path

  • PortIndex — Port index

  • PortType — Type of port logged

  • Values — Logged time and data

The results returned by the find function are not limited to one object type. The find function can return a Dataset object containing elements of any object type that have the specified property type with the specified value. For example, suppose a Dataset object contains two elements with the name myName, where one element is a Signal object and the other element is a timeseries object. You can use the find function to search for both elements by specifying the property type as Name and the property value as myName.

dsName = find(ds,"Name","myName")
dsName = 

Simulink.SimulationData.Dataset 'myDataset' with 2 elements

                             Name    BlockPath 
                             ______  _________ 
    1  [1x1 timeseries]      myName  ''       
    2  [1x1 Signal    ]      myName  ''       

  - Use braces { } to access, modify, or add elements using index.

Property value to search for, specified as a string or character vector. The property value can be a regular expression when using the '-regexp' argument.

Logical operator connecting multiple property type and value pairs, specified as '-and' or '-or'.

If you do not specify an operation, the function assumes '-and'.

Output Arguments

collapse all

Dataset object that contains the elements that match one or more property type and value pairs, returned as a Simulink.SimulationData.Dataset object. If no elements match the specified property type and value, the returned Dataset object is empty.

Indices in the Dataset object dsIn of the elements that match the specified property name and property value, returned as a vector. If no elements match the specified property type and value, then idx is empty.

Alternatives

You can use curly braces to streamline the indexing syntax to access an element in a Dataset object instead of using the find function. The index must be a positive integer that is not greater than the number of elements in the variable. For example, find the second element of the logsout dataset.

logsout{2}

You can also use the get function to get an element or collection of elements from a dataset.

Version History

Introduced in R2015b