Main Content

hasPath

Determine whether operating point data contains element at specified path

Description

hasPath(op,opPath) returns true (1) if the operating point data tree contains a node corresponding to the specified relative path, opPath. Returns false (0) if a matching node was not found.

example

Examples

collapse all

When you determine the relative path for a block, the operating point does not need to contain a node corresponding to that block. Use the hasPath function to determine whether the operating point contains data at the specified location.

Open the Permanent Magnet DC Motor example model and create an OperatingPoint object named op using the Start values from the model:

openExample('simscape/PermanentMagnetDCMotorExample')
op = simscape.op.create(gcs, 'Start')
op = 

  OperatingPoint with children:

  OperatingPoints:

   ChildId         Size
   ______________  ____

   'DC Motor'       1x1
   'DC Voltage'     1x1
   'ERef'           1x1
   'Load Torque'    1x1
   'MRRef Motor'    1x1
   'MRRef Torque'   1x1
   'Sensing'        1x1
   'Step Input'     1x1

Open the DC Motor subsystem, select the Inductor block, and find the relative path to this block in the operating point data hierarchy:

 relPath = relativePath(op, gcb)
relPath =

    'DC Motor/Rotor Inductance'

Now determine whether the operating point contains data for this block:

 hasPath(op, relPath)
ans =

  logical

   1

Input Arguments

collapse all

Operating point in the workspace, specified as an OperatingPoint object.

Relative path in the operating point data tree, specified as a slash-delimited character vector or string scalar. Use the relativePath function to determine the path to an element. The element can be a subsystem, block, or variable target.

Data Types: char | string

Version History

Introduced in R2017b