setVariableValue
Class: mlreportgen.report.MATLABVariable
Package: mlreportgen.report
Syntax
setVariableValue(rptr,value)
Description
setVariableValue(
sets the value of the variable reported by the specified reporter to the specified value and
sets the rptr
,value
)Location
property of the reporter to
"User-Defined"
.
Input Arguments
rptr
— MATLAB variable reporter
mlreportgen.report.MATLABVariable
object
MATLAB® variable reporter, specified as an
mlreportgen.report.MATLABVariable
object.
value
— Value to report
(default) | Any MATLAB data type
Value to report, specified as any MATLAB data type.
Examples
Set Value for MATLABVariable
Reporter to Report
This example shows how to report values that are not assigned to variables in the MATLAB® workspace. The example creates a containers.Map
object. The Map
object is defined in the MATLAB workspace, but the key-value pair entries are not assigned to variables in the workspace. To report on the entries, the example creates a reporter for each entry in the Map
object, gets the entry value from the Map
object, and then uses setVariableValue
to specify the value to report.
Import the Report API package so that you do not have to use long, fully qualifed class names.
import mlreportgen.report.*
Create a Map
object.
myMap = containers.Map(["key1","key2"],[100,200]);
Create a report.
report = mlreportgen.report.Report("My Report","PDF");
Determine the number of key-value pair entries in the Map
object.
n = length(myMap);
Return the keys of the Map
object in a cell array.
myKeys = keys(myMap);
Create a reporter for each entry in the Map
object. Use setVariableValue
to set the value to report for the entry.
for i=1:n myKey = myKeys{i}; rptr = mlreportgen.report.MATLABVariable(); rptr.Variable = myKey; setVariableValue(rptr,myMap(myKey)); append(report,rptr); end
Close and view the report.
close(report); rptview(report);
Here are the key-value pairs in the report:
Version History
Introduced in R2020b
Ouvrir l'exemple
Vous possédez une version modifiée de cet exemple. Souhaitez-vous ouvrir cet exemple avec vos modifications ?
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes 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)