Main Content

copy

Class: mlreportgen.report.Reporter
Namespace: mlreportgen.report

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

Since R2020a

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, DOM object, or mlreportgen.report.ReporterLayout 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 MATLABVariable 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 MATLABVariable object does not affect the original MATLABVariable object.

import mlreportgen.report.*

obj1 = MATLABVariable;

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

obj1.TextFormatter.Bold
ans =

     []

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

obj2 = copy(obj1);
obj2.TextFormatter.Bold = true;

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

obj1.TextFormatter.Bold
ans =

     []

More About

expand all

Version History

Introduced in R2020a