Main Content

copy

Class: mlreportgen.report.Reporter
Package: mlreportgen.report

Create copy of reporter object and make deep copies of property values that reference a reporter, ReporterLayout, or DOM object

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, mlreportgen.report.ReporterLayout object, 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 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

Introduced in R2020a