Main Content

copy

Copy operating point or operating point specification

Syntax

op_point2 = copy(op_point1)
op_spec2 = copy(op_spec1)

Description

op_point2 = copy(op_point1) returns a copy of the operating point object op_point1. You can create op_point1 with the function operpoint.

op_spec2 = copy(op_spec1) returns a copy of the operating point specification object op_spec1. You can create op_spec1 with the function operspec.

Note

The command op_point2 = op_point1 does not create a copy of op_point1 but instead creates a pointer to op_point1. In this case, any changes made to op_point2 are also made to op_point1. The same is true for operating point specifications. For an example, see Copy an Operating-Point Specification.

Examples

collapse all

You can create new operspec variables in three ways:

  • Using the operspec command

  • Using assignment with the equals (=) operator

  • Using the copy command

Using the = operator results in linked variables that both point to the same underlying data. Using the copy command results in an independent operspec object. In this example, create operspec objects both ways, and examine their behavior.

mdl = 'watertank';
open_system(mdl)
opspec1 = operspec(mdl)
opspec1 = 
 Operating point specification for the Model watertank.
 (Time-Varying Components Evaluated at time t=0)

States: 
----------
     x         Known    SteadyState     Min         Max        dxMin       dxMax   
___________ ___________ ___________ ___________ ___________ ___________ ___________
                                                                                   
(1.) watertank/PID Controller/Integrator/Continuous/Integrator
     0         false       true        -Inf         Inf        -Inf         Inf    
(2.) watertank/Water-Tank System/H
     1         false       true          0          Inf        -Inf         Inf    

Inputs: None 
----------

Outputs: None 
----------

Create a new operating point specification object using assignment with the = operator.

opspec2 = opspec1;

opspec2 is an operspec object that points to the same underlying data as opspec1. Because of this link, you cannot independently change properties of the two operspec objects. To see this, change a property of opspec2. For instance, change the initial value for the first state from 0 to 2. The change shows in the States section of the display.

opspec2.States(1).x = 2
opspec2 = 
 Operating point specification for the Model watertank.
 (Time-Varying Components Evaluated at time t=0)

States: 
----------
     x         Known    SteadyState     Min         Max        dxMin       dxMax   
___________ ___________ ___________ ___________ ___________ ___________ ___________
                                                                                   
(1.) watertank/PID Controller/Integrator/Continuous/Integrator
     2         false       true        -Inf         Inf        -Inf         Inf    
(2.) watertank/Water-Tank System/H
     1         false       true          0          Inf        -Inf         Inf    

Inputs: None 
----------

Outputs: None 
----------

Examine the display of opspec1 to see that the corresponding property value of opspec1 also changes from 0 to 2.

opspec1
opspec1 = 
 Operating point specification for the Model watertank.
 (Time-Varying Components Evaluated at time t=0)

States: 
----------
     x         Known    SteadyState     Min         Max        dxMin       dxMax   
___________ ___________ ___________ ___________ ___________ ___________ ___________
                                                                                   
(1.) watertank/PID Controller/Integrator/Continuous/Integrator
     2         false       true        -Inf         Inf        -Inf         Inf    
(2.) watertank/Water-Tank System/H
     1         false       true          0          Inf        -Inf         Inf    

Inputs: None 
----------

Outputs: None 
----------

To create an independent copy of an operating point specification, use the copy command.

opspec3 = copy(opspec1);

Now, when you change a property of opspec3, opspec1 does not change. For instance, change the initial value for the first state from 2 to 4.

opspec3.States(1).x = 4
opspec3 = 
 Operating point specification for the Model watertank.
 (Time-Varying Components Evaluated at time t=0)

States: 
----------
     x         Known    SteadyState     Min         Max        dxMin       dxMax   
___________ ___________ ___________ ___________ ___________ ___________ ___________
                                                                                   
(1.) watertank/PID Controller/Integrator/Continuous/Integrator
     4         false       true        -Inf         Inf        -Inf         Inf    
(2.) watertank/Water-Tank System/H
     1         false       true          0          Inf        -Inf         Inf    

Inputs: None 
----------

Outputs: None 
----------

In opspec1, the corresponding value remains 2.

opspec1.States(1).x
ans = 
2

This copy behavior occurs because operspec is a handle object. For more information about handle objects, see Handle Object Behavior.

You can create new operating-point variables in three ways:

  • Using the operpoint function

  • Using assignment with the equals (=) operator

  • Using the copy function

Using the = operator results in linked variables that both point to the same underlying data. Using the copy function results in an independent operating-point object. In this example, create operating-point objects both ways, and examine their behavior.

mdl = 'watertank';
open_system(mdl)
op1 = operpoint(mdl)
op1 = 
 Operating point for the Model watertank.
 (Time-Varying Components Evaluated at time t=0)

States: 
----------
x
_
 
(1.) watertank/PID Controller/Integrator/Continuous/Integrator
0
(2.) watertank/Water-Tank System/H
1

Inputs: None 
----------

Create a new operating-point object using assignment with the = operator.

op2 = op1;

op2 is an operating-point object that points to the same underlying data as op1. Because of this link, you cannot independently change properties of the two operating-point objects. To see this, change a property of op2. For instance, change the value for the first state from 0 to 2. The change shows in the States section of the display.

op2.States(1).x = 2
op2 = 
 Operating point for the Model watertank.
 (Time-Varying Components Evaluated at time t=0)

States: 
----------
x
_
 
(1.) watertank/PID Controller/Integrator/Continuous/Integrator
2
(2.) watertank/Water-Tank System/H
1

Inputs: None 
----------

Examine the display of op1 to see that the corresponding property value of op1 also changes from 0 to 2.

op1
op1 = 
 Operating point for the Model watertank.
 (Time-Varying Components Evaluated at time t=0)

States: 
----------
x
_
 
(1.) watertank/PID Controller/Integrator/Continuous/Integrator
2
(2.) watertank/Water-Tank System/H
1

Inputs: None 
----------

To create an independent copy of an operating-point object, use the copy function.

op3 = copy(op1);

Now, when you change a property of op3, op1 does not change. For instance, change the value for the first state from 2 to 4.

op3.States(1).x = 4
op3 = 
 Operating point for the Model watertank.
 (Time-Varying Components Evaluated at time t=0)

States: 
----------
x
_
 
(1.) watertank/PID Controller/Integrator/Continuous/Integrator
4
(2.) watertank/Water-Tank System/H
1

Inputs: None 
----------

In op1, the corresponding value remains 2.

op1.States(1).x
ans = 
2

This copy behavior occurs because the operating-point object is a handle object. For more information about handle objects, see Handle Object Behavior.

Version History

Introduced before R2006a