Main Content

merge

Create operating point by merging data from two operating points

Description

example

opNew = merge(op1, op2) creates a new OperatingPoint object opNew, with children from two OperatingPoint objects, op1 and op2.

The function starts by copying all children from op1 into opNew. Then, if a child ID exists in op2 but not in op1, the function adds the child to opNew. If a child ID exists both in op1 and op2, then:

  • If both children are OperatingPoint objects, the function merges them according to the same rules.

  • If at least one of the two children is a Target object, the function retains the child of op1 and discards the child of op2.

Examples

collapse all

Create the first OperatingPoint object, op1.

t1 = simscape.op.Target(1.5, 'V', 'High');
op1 = simscape.op.OperatingPoint;
op1 = set (op1, 'V0', t1);
op1 = set (op1, 'V1', t1)
op1 = 
  OperatingPoint with children:

  Targets:

   ChildId   Value  Unit  Priority
   _______  ______  ____  ________

   'V0'     1.5000  'V'     'High'
   'V1'     1.5000  'V'     'High'

This operating point has two children, Target objects V0 and V1.

Create the second OperatingPoint object, op2.

t2 = simscape.op.Target(1, 'V');
op2 = simscape.op.OperatingPoint;
op2 = set (op2, 'V1', t2);
op2 = set (op2, 'V2', t2)
op2 = 

  OperatingPoint with children:

  Targets:

   ChildId  Value  Unit  Priority
   _______  _____  ____  ________

   'V1'         1  'V'     'None'
   'V2'         1  'V'     'None'

This operating point has two children, Target objects V1 and V2.

Merge the two operating points into a new OperatingPoint object, op.

op = merge (op1, op2)
op = 

  OperatingPoint with children:

  Targets:

   ChildId   Value  Unit  Priority
   _______  ______  ____  ________

   'V0'     1.5000  'V'     'High'
   'V1'     1.5000  'V'     'High'
   'V2'          1  'V'     'None'

The new operating point has two children from the first operating point, V0 and V1, and the V2 child from the second operating point. The V1 target from the second operating point is discarded because it conflicts with the child ID existing in the first operating point.

Input Arguments

collapse all

First operating point to be merged, specified as an OperatingPoint object.

Second operating point to be merged, specified as an OperatingPoint object.

Output Arguments

collapse all

New OperatingPoint object, which contains children from op1 and op2.

Version History

Introduced in R2017b