主要内容

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

getVariableValue

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

从模型变量搜索结果中获取变量的值

语法

value = getVariableValue(variableResult)

说明

value = getVariableValue(variableResult) 返回模型变量搜索结果所表示的变量的值。

输入参数

全部展开

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

示例

全部展开

如果 getVariableValue 方法返回 Simulink.Bus 对象,则使用 slreportgen.report.BusObject 对象而不是 slreportgen.report.ModelVariable 对象来报告总线对象。

mdl = "sldemo_bus_arrays";
load_system(mdl);

rpt = slreportgen.report.Report("ExampleBusReport", "pdf");

% Find variables used by the model
f = slreportgen.finder.ModelVariableFinder(mdl);
results = find(f);

for r = results
    % If the result represents a Bus object, add a Bus 
    % object reporter to the report
    if isa(getVariableValue(r), "Simulink.Bus")
        reporter = slreportgen.report.BusObject(r);
        % Add the reporter to a chapter in the report
        ch = mlreportgen.report.Chapter(reporter.Name);
        add(ch, reporter);
        add(rpt, ch);
    end
end

% Close and view the report
close(rpt);
rptview(rpt);

版本历史记录

在 R2019b 中推出