Main Content


Determine whether operating point data contains element at specified path



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.


collapse all

When you determine 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:

op = simscape.op.create(gcs, 'Start')
op = 

  OperatingPoint with children:


   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 =



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

Introduced in R2017b