Main Content

本页采用了机器翻译。点击此处可查看英文原文。

getReporter

类: slreportgen.finder.ModelVariableResult
命名空间: slreportgen.finder

获取模型变量搜索结果的报告器

语法

reporter = getReporter(variableResult)

说明

reporter = getReporter(variableResult) 返回模型变量搜索结果的 slreportgen.report.ModelVariable 对象。

输入参数

全部展开

使用 slreportgen.finder.ModelVariableFinder 对象的 findnext 方法进行搜索的结果。

输出参量

全部展开

报告器在报告中包含有关模型变量的信息。通过设置报告器的属性来自定义变量信息的内容和格式。

示例

全部展开

通过设置报告器属性来自定义报告中模型变量的格式。

% Create a Report
rpt = slreportgen.report.Report("MyReport","pdf");

% Create a Chapter
chapter = mlreportgen.report.Chapter();
chapter.Title = "Model Variable Reporter Example";

% Load the model
model_name = "sf_car";
load_system(model_name);

% Find the variables in the model
finder = slreportgen.finder.ModelVariableFinder(model_name);

while hasNext(finder)
    result = next(finder);
    
    % Get the ModelVariable reporter for the result
    % Customize the formatting of numbers
    reporter = getReporter(result);
    reporter.NumericFormat = "%.4f";
    
    % Add the reporter to the chapter
    add(chapter,reporter);
end
% Add chapter to the report
add(rpt,chapter);

% Close the report and open the viewer
close(rpt);
rptview(rpt);

版本历史记录

在 R2019b 中推出