Main Content

getPropertyValues

Class: mlreportgen.finder.MATLABVariableResult
Namespace: mlreportgen.finder

Get property values of MATLAB variable search result object

Since R2022a

Description

propVals = getPropertyValues(resObj,propNames) returns the values of the properties specified by propNames in the MATLAB® variable search result object, resObj. The specified properties can belong to the result object or to the variable represented by the result object.

Input Arguments

expand all

MATLAB variable search result, specified as an mlreportgen.finder.MATLABVariableResult object.

List of requested properties, specified as a string array or a cell array of strings. Valid values for elements in the array are, in any order:

Requested PropertyReturned Value
"Name"Name of the variable, specified as a string scalar
"Class"Data type of the variable, specified as a character vector
"Size"Dimensions of the variable, specified as a double array
"Bytes"Number of bytes used for storing the variable in the computer memory, specified as a double scalar
"Sparse"Whether the variable is a sparse matrix, specified as a logical
"Complex"Whether the variable is a complex number, specified as a logical
"Value"Value of the variable
"Global"Whether the variable is global, specified as a logical
The name of any property of resObjThe value of the property
The name of any property of resObj that can be accessed by dot notation. Note: This option only applies to variables of type struct or to variables that are instances of classes.The value of the property

Note

If the variable represented by resObj has a property with the same name as a property of resObj, the method getPropertyValues retrieves the property value of resObj. For example:

  1. In the base workspace, define a struct with a field named Place and a field named Location.

    myStruct.Place = "USA";
    myStruct.Location = "America";
    

  2. Use the find method to create a MATLABVariableResult object for the structure myStruct.

    resObj = find(mlreportgen.finder.MATLABVariableFinder(...
                                  Container="MATLAB",Name="myStruct"));
    

  3. Use the getPropertyValues method to get the values of the Place and Location properties.

    getPropertyValues(resObj,["Place","Location"])
    

    The value of the Location property is "MATLAB" from resObj.

    ans =
    
      1×2 cell array
    
        {["USA"]}    {["MATLAB"]}
    

Output Arguments

expand all

Values of the specified properties, returned as a cell array.

Version History

Introduced in R2022a