# 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

### Copy an Operating-Point Specification

You can create new `operspec`

variables in three ways:

Using the

`operspec`

commandUsing assignment with the equals (

`=`

) operatorUsing 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.

### Copy an Operating Point

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

Using the

`operpoint`

functionUsing assignment with the equals (

`=`

) operatorUsing 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**

## MATLAB 명령

다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.

명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)