mlreportgen.finder.MATLABVariableResult Class
Namespace: mlreportgen.finder
Superclasses: mlreportgen.finder.Result
Description
An object of the mlreportgen.finder.MATLABVariableResult
class is the
result of a search for MATLAB® variables. A MATLABVariableResult
object contains information
about a single variable. Each MATLABVariableResult
object is associated with an
mlreportgen.report.MATLABVariable
reporter object that represents the same
MATLAB variable. To report on the variable, add the MATLABVariableResult
object to a generated report.
The mlreportgen.finder.MATLABVariableResult
class is a handle
class.
Creation
You do not create MATLABVariableResult
objects explicitly. The
MATLABVariableFinder
methods find
and next
create a
MATLABVariableResult
object for each variable they find.
Properties
Object
— Name of variable
string scalar
Name of the variable represented by this MATLABVariableResult
object,
returned as a string scalar.
Attributes
GetAccess | public |
SetAccess | protected |
Data Types: string
Location
— Workspace in which the variable is defined
"MATLAB" | "Global" | "MAT-File"
Workspace in which the variable is defined, specified as one of these values:
Value | Workspace |
---|---|
"MATLAB" | Base workspace |
"Global" | Global workspace |
"MAT-File" | A MAT-file |
Attributes
GetAccess | public |
SetAccess | Restricts access |
Data Types: string
FileName
— Name of MAT-File in which variable is defined
string scalar | []
Name of the MAT-file in which the variable is defined, specified as a string scalar.
If the variable is not defined in a MAT-file, FileName
is
empty.
Attributes
GetAccess | public |
SetAccess | Restricts access |
Data Types: string
Tag
— Optional label
[]
(default) | any object
Optional label, specified as any type of MATLAB variable.
Attributes
GetAccess | public |
SetAccess | public |
Methods
Public Methods
getReporter |
|
getReporterLinkTargetID |
|
getDefaultSummaryTableTitle |
|
getDefaultSummaryProperties |
|
getPropertyValues | Get property values of MATLAB variable search result object |
Examples
Add Summary Tables of MATLAB® Variables to a Report
This example shows how to add summary tables with information about MATLAB® variables to a report.
Import these packages so that you do not have to use long, fully qualified class names.
import mlreportgen.report.* import mlreportgen.finder.* import mlreportgen.dom.*
Define variables and global variables of different data types and sizes in the base workspace.
global gvar_string gvar_str_arr_2x3 gvar_uint8_arr_9x3; gvar_string = "this is my string scalar variable"; gvar_str_arr_2x3 = ["str 1.1","str 1.2","str 1.3";"str 2.1","str 2.2","str 2.3"]; gvar_uint8_arr_9x3 = uint8(randi(255,9,3)); var_char_arr = 'this is my character vector variable'; var_double_3x5x6 = rand(3,5,6); var_cell_arr_7x8x9 = num2cell(rand(7,8,9));
Create an mlreportgen.report.Report
object of type PDF. Then create a title and append it to the Report
object.
rpt = Report("Summary_of_variables_example","pdf"); docHeader = Heading(1,"Summary of variables we found:"); append(rpt,docHeader);
Use the mlreportgen.finder.MATLABVariableFinder.find
method to find the variables in the base workspace, and create an array of mlreportgen.finder.MATLABVariableResult
objects that represent the variables.
results = find(MATLABVariableFinder());
Create an mlreportgen.report.SummaryTable
object with the result array. The default title of the table is the return value of the getDefaultSummaryTableTitle
method, and the default list of properties to be reported in the table is the return value of the getDefaultSummaryProperties
method. Leave the title of the table and list of properties to be reported in the table unchanged.
table1 = SummaryTable(results);
Create a second SummaryTable
object with the result array. Then set the title of this table to "global or not"
, and set the properties to be reported by this table to "Name"
and "Global"
.
table2 = SummaryTable(results); table2.Title = "global or not"; table2.Properties = ["Name","Global"];
Append the two summary tables to the report. Then close and view the report.
append(rpt,table1); append(rpt,table2); close(rpt); rptview(rpt);
Link to MATLAB® Variable in Report
This example shows how to create a hyperlink to a variable in a report.
Import these packages so that you do not have to use long, fully qualified class names.
import mlreportgen.report.* import mlreportgen.finder.* import mlreportgen.dom.*
Define variables in the base workspace.
for index = 1:99 evalin("base",sprintf("var_%0.3i='this is the content of var_%0.2i';",index,index)); end
Create an mlreportgen.report.Report
object of type HTML. Then create a title and append it to the Report
object.
rpt = Report("MATLABVariableResult_hyperlink_Example","html-file"); header = Heading(1,"These are the variables we found:"); append(rpt,header);
Use the mlreportgen.finder.MATLABVariableFinder.find
method to find variables in the base workspace that have names beginning with "var"
, and create a vector of mlreportgen.finder.MATLABVariableResult
objects that represent the variables. Then append the result objects to the report.
results = find(MATLABVariableFinder(Name="^var"));
append(rpt,results);
Create an mlreportgen.dom.InternalLink
object with the link target ID of result number 31. Then append the InternalLink
object to the report.
targetID = getReporterLinkTargetID(results(31));
link = InternalLink(targetID,"Jump to result #31");
append(rpt,link);
Close and view the report.
close(rpt); rptview(rpt);
Scroll to the bottom of the report to test the hyperlink.
Version History
Introduced in R2022a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)