Main Content

copy

Class: slreportgen.report.Reporter
Namespace: slreportgen.report

Create copy of a Simulink reporter object and make deep copies of certain property values

Since R2021a

Syntax

reporterObj2 = copy(reporterObj1)

Description

reporterObj2 = copy(reporterObj1) returns a copy of the specified reporter object. The returned copy contains a deep copy of any property value of reporterObj1 that references a reporter or DOM object. As a result, the corresponding property value in reporterObj2 refers to a new, independent object. You can modify the properties of the original or new object without affecting the other object.

Input Arguments

expand all

Reporter to copy, specified as an object of a reporter class.

Output Arguments

expand all

Copy of reporter, returned as an object of a reporter class.

Examples

expand all

This example copies a DocBlock reporter to show the effect of a deep copy operation on a reporter property. Modifying a property of the Text object in the TextFormatter property of the copy of the DocBlock object does not affect the original DocBlock object.

Load a model.

import slreportgen.report.*

model_name = "slrgex_fuelsys";
load_system(model_name);
docBlock = "slrgex_fuelsys/To Controller/Sensor Info";

Create a DocBlock reporter.

rptr1 = DocBlock(docBlock);

The Bold property of the Text object referenced by the TextFormatter property of the reporter is empty.

rptr1.TextFormatter.Bold
ans =

     []

Copy the DocBlock object. In the copy, set the Bold property of the Text object referenced by the TextFormatter property to true.

rptr2 = copy(rptr1);
rptr2.TextFormatter.Bold = true;
rptr2.TextFormatter.Bold
ans = logical
   1

In the original DocBlock object, the Bold property of the object referenced by the TextFormatter property is still empty.

rptr1.TextFormatter.Bold
ans =

     []

More About

expand all

Version History

Introduced in R2021a