Main Content

slreportgen.report.LookupTable Class

Namespace: slreportgen.report
Superclasses: slreportgen.report.Reporter

Lookup table block reporter

Description

Create a Simulink® lookup table block reporter_ See the Object property for a list of supported blocks.

Note

To use a LookupTable reporter in a report, you must create the report using the slreportgen.report.Report class.

The slreportgen.report.LookupTable class is a handle class.

Creation

Description

example

rptr = LookupTable creates an empty LookupTable block reporter based on a default template. Use its properties to specify the lookup table block on which to report and specify report options.

example

rptr = LookupTable(lutobj) creates a LookupTable block reporter for the lookup table block specified by lutobj. By default, the reporter generates a table and a plot of output values versus breakpoints, and a data types table.

example

rptr = LookupTable(Name=Value) sets LookupTable reporter properties using name-value pairs. You can specify multiple name-value pair arguments in any order.

Input Arguments

expand all

See the Object property.

Properties

expand all

Lookup table block to report on, specified as the path or handle of the block.

These lookup table blocks are supported.

Note

If you use a finder to find a Lookup Table block and add it directly to a report, this LookupTable reporter is used rather than a Simulink object property reporter.

Whether to include a table of lookup table data, specified as a logical. If true, the report includes a table that lists output values and breakpoints of the lookup table.

For a 1-D lookup table, the data table lists the breakpoints in the first column of the table. The second column lists the corresponding output values.

For a 2-D or greater dimension lookup table, the data table lists the first set of breakpoints in the first row of the table. It lists the second set of breakpoints in the first column. The output appears in the corresponding table cells. For lookup tables greater than 2-D, the LookupTable report generator shows slices of the table as separate output versus breakpoint tables.

Whether to include a lookup table data plot, specified as a logical. If true, the report includes a plot of the output values versus the breakpoints of the lookup table block.

For a 1-D lookup table, the plot is a line plot of output values versus breakpoints.

For 2-D tables and slices, the plot is a surface or mesh plot of output values versus breakpoints. Use the PlotType property to specify whether to use a surface or mesh plot.

Plot type for a 2-D lookup table data plot, specified as either a character array ('Surface Plot' or 'Mesh Plot') or string ("Surface Plot" or "Mesh Plot").

Lookup table data reporter, specified as a BaseTable reporter or custom reporter. The LookupTable reporter uses the specified reporter to create a table of lookup table data.

To customize the appearance of the table of lookup table data, customize the default BaseTable reporter or replace it with a custom version of the BaseTable reporter.

To customize the title of the table of lookup table data, specify the contents in the Title property of the default or replacement reporter. The content you specify is placed at the front of the default title. If the lookup table is too wide to fit legibly on a page, use the MaxCols property of the DataReporter to generate the table as a set of slices that fit legibly. To determine an optimal value, iterate setting the MaxCols value and viewing the report.

Example: lutable.DataReporter.Title = 'New Title'

Lookup table data plot reporter, specified as a Figure reporter or custom reporter. The LookupTable reporter uses the specified reporter to create a plot of output values versus breakpoints of the lookup table.

To customize the appearance of the plot of the lookup table data, customize the default Figure reporter or replace it with a custom version of the Figure reporter. To customize the caption of the plot, specify the contents in the Caption property of the default or replacement reporter. The content you specify is placed at the front of the default caption.

Maximum number of table columns to display for the output values versus breakpoints, specified as inf or an integer. This property applies only if the IncludeTable property is true.

If the number of lookup table columns is greater than the value of this property, the data is shown only as a surface plot. The plot appears only if the IncludePlot property is true.

The default value of this property is inf, which causes the reporter to use a table regardless of the size of the lookup table data array. Depending on the size of the data being displayed, some tables can be illegible. To avoid creation of illegible tables, change the default setting of this property to a smaller value.

Source of the template for this reporter, specified as one of these options:

  • Character vector or string scalar that specifies the path of the file that contains the template for this reporter

  • Reporter or report whose template is used for this reporter or whose template library contains the template for this reporter

  • DOM document or document part whose template is used for this reporter or whose template library contains the template for this reporter

The specified template must be the same type as the report to which this reporter is appended. For example, for a Microsoft® Word report, TemplateSrc must be a Word reporter template. If the TemplateSrc property is empty, this reporter uses the default reporter template for the output type of the report.

Name of template for this reporter, specified as a character vector or string scalar. The template for this reporter must be in the template library of the template source (TemplateSrc) for this reporter.

Hyperlink target for this reporter, specified as a character vector or string scalar that specifies the link target ID or as an mlreportgen.dom.LinkTarget object. A character vector or string scalar value is converted to a LinkTarget object. The link target immediately precedes the content of this reporter in the output report.

Methods

expand all

Examples

collapse all

This example shows how to add fixed content to a customized HTML LookupTable reporter template. You can also customize your lookup table report output by editing the report generator program directly. The advantage of customizing a template is that you can reuse it as a basis for customizing another report generator program.

The template and style sheets for the LookupTable reporter are located in the matlab\toolbox\shared\slreportgen\rpt\rpt\+slreportgen\+report\@LookupTable\resources\templates folder. You do not need to specify this path when you copy the default template.

  1. Create a copy of the default html template. In this example, the template package is saved as a zipped file named CustomTemplate.htmtx in the current working folder.

    import mlreportgen.report.*
    import slreportgen.report.*
    
    LookupTable.createTemplate('CustomTemplate','html');
    

  2. Unzip the template package.

    unzipTemplate('CustomTemplate.htmtx');
    The unzipped template package is a folder of document, style sheet, and image files. In this example, the unzipped folder of files is named CustomTemplate and is saved in the current working folder. The root.css file, which is in the stylesheets subfolder, defines the styles that control the appearance and formatting of the generated report. The docpart_templates.html file specifies the holes that hold the report contents when the report is generated.

  3. From the CustomTemplate folder, open the docpart_templates.html file in a text editor outside of MATLAB.

    <html>
      <head>
        <meta charset="utf-8" />
        <title>Document Part Templates</title>
        <link rel="StyleSheet" href="./stylesheets/root.css" type="text/css" />
      </head>  <body>
        <dplibrary>
            
          <!-- NOTE: temporary in the template library until the -->
          <!   DOM supports a source without template name -->
          <dptemplate name="LookupTable">
             <hole id="Content">LUT_CONTENT</hole>
             <hole id="LUTDataTypes">DATA_TYPE</hole>
             <hole id="FootNoteContent">LUT_FOOTNOTE_CONTENT</hole>
          </dptemplate>
          <dptemplate name="LookupTableContent">
             <hole id="TableContent">TABLECONTENT</hole>
             <hole id="FigureContent">FIGURECONTENT</hole>
          </dptemplate>
        </dplibrary>
      </body>
    </html>

  4. To add fixed text to the template, place it in the desired location and use standard HTML tagging. This example adds text that appears above the data types table in the generated report. Only the <dptemplate name="LookupTable"> portion of the file is shown.

          <dptemplate name="LookupTable">
             <hole id="Content">LUT_CONTENT</hole>
             <p><scan>This lookup table block contains the following 
                data types:</scan></p>
             <hole id="LUTDataTypes">DATA_TYPE</hole>
             <hole id="FootNoteContent">LUT_FOOTNOTE_CONTENT</hole>
          </dptemplate>
    

  5. Save the file.

  6. At the MATLAB command line, zip the template folder into a template package. For this example, the template package is zipped to the CustomTemplate.htmtx file.

    zipTemplate('CustomTemplate');

  7. To use the saved template for your report, specify the template source in your report generator program.

    lutable = LookupTable();
    lutable.TemplateSrc = 'CustomTemplate';

Create a PDF report generator that specifies the plot height and width returned by the LookupTable reporter. This example uses the sf_car model and reports on its Torque ratio Lookup Table (n-D) block. This block is a 1-D lookup table and is in the transmission/Torque Converter subsystem of the sf_car model. To set the height and width of the plot, use the PlotReporter property.

import slreportgen.report.*
import mlreportgen.report.*

model_name = "sf_car";
load_system(model_name); 
lutable = "sf_car/transmission/Torque Converter/Torque ratio";

rpt = slreportgen.report.Report("output","pdf");
chapter = Chapter(lutable); 

rptr = LookupTable(lutable);
rptr.IncludeTable = false;
add(chapter,rptr);

rptr_resized = LookupTable(lutable);
rptr_resized.IncludeTable = false;
rptr_resized.PlotReporter.Snapshot.Width = "3in";
rptr_resized.PlotReporter.Snapshot.Height = "4in";
add(chapter,rptr_resized);

add(rpt,chapter);

close(rpt) ;
close_system(model_name)
rptview(rpt);

The default plot on the first page of the report uses predefined sizing to fit the plot to the page size.

lutable_refpg_ex2a.png

The resized plot on the second page of the report uses the specified 3" width and 4" height.

lutable_refpg_ex2b.png

Create a PDF report generator that reports on a lookup table block. This example uses the sf_car model and reports on its engine torque Lookup Table (n-D) block. This block is a 2-D lookup table. The engine torque block is in the Engine subsystem of the sf_car model. The report, by default, includes a table of output values versus breakpoints, a surface plot, a table of block data types, and notes about possible differences between reported values and values obtained from simulation.

import slreportgen.report.*
import mlreportgen.report.*

model_name = "sf_car";
load_system(model_name); 
lutable = "sf_car/Engine/engine torque";

rpt = slreportgen.report.Report('output','pdf');
chapter = Chapter(lutable); 
rptr = LookupTable(lutable); 
add(chapter,rptr);
add(rpt,chapter);

close(rpt); 
close_system(model_name);
rptview(rpt)

Create a PDF report generator that finds all blocks in the Engine subsystem of the sf_car model. The report generator program then loops through the blocks and tests whether the block is a lookup table block. For lookup table blocks, it uses the LookupTable reporter to report information about the block. For other blocks, the generated report reports on block properties, which are the results of the BlockFinder class.

Run the following command to access the supporting files used in this example.

openExample('rptgenext/SimulinkReportGeneratorFilesExample');
import slreportgen.report.*
import slreportgen.finder.*

model_name = "sf_car";
load_system(model_name)
subsys_name = "sf_car/Engine";
rpt = slreportgen.report.Report;

blkfinder = BlockFinder(subsys_name);
blks = find(blkfinder);

for i=1:length(blks)
   if slreportgen.utils.isLookupTable(blks(i).Object)
      rptr = LookupTable(blks(i).Object);
      ch = Chapter(blks(i).Name);
      add(ch,rptr);
      add(rpt,ch);
   else
      ch = Chapter(blks(i).Name);
      add(ch,blks(i));
      add(rpt,ch);
   end
end

close(rpt);
close_system(model_name);
rptview(rpt);

The first chapter shows the default properties reported for Inport block.

The fifth chapter shows the default output for a Lookup Table block reporter. The default output is a table of output values versus breakpoints table, a plot, and a table of data types.

Version History

Introduced in R2018a