This example shows how to create a report that describes all of the the bus objects used by a Simulink® model. This report creates a chapter for each bus object. Each chapter has a section for the bus object hierarchy, bus object properties table, bus elements properties table, and list of blocks that use the bus.
Open a model that has bus objects.
model = "sldemo_bus_arrays"; open_system(model);
Create and open a report object.
rpt = slreportgen.report.Report(model + "_bus_object_report","pdf"); open(rpt);
Add a title page and a table of contents.
titlepage = mlreportgen.report.TitlePage("Title", model + ": Bus Object Report","Author","John Doe"); add(rpt,titlepage); toc = mlreportgen.report.TableOfContents(); add(rpt, toc);
Find all the variables used in the model.
finder = slreportgen.finder.ModelVariableFinder(model);
Loop through the variable finder results to find the bus objects and report on them. Use the
getVariableValue method to identify which variables are bus objects. Use the
slreportgen.report.BusObject reporter to report on the bus objects.
while hasNext(finder) result = next(finder); if isa(getVariableValue(result),"Simulink.Bus") % Create a Bus object reporter busReporter = slreportgen.report.BusObject(result); % Create a Chapter chapter = mlreportgen.report.Chapter(busReporter.Name); % Add bus to chapter add(chapter,busReporter) % Add chapter to the report add(rpt,chapter); end end
Close and view the report.
To see a more comprehensive bus object report, view the
asbhl20_bus_object_report.pdf that is available with this example. You must have Aerospace Blockset™ to open the