Main Content


Class: slreportgen.finder.DiagramElementResult
Package: slreportgen.finder

Returns Diagram reporter for diagram element result


reporter = getDiagramReporter(result)


reporter = getDiagramReporter(result) returns a reporter that generates a snapshot of the element returned in the diagram element result, or empty, []. If the result contains a diagram element, such as a Simulink® block, or Stateflow® chart or subchart, that contains a diagram, this method returns a reporter that generates a snapshot of the diagram. Otherwise, it returns empty, []. For example, this method returns a diagram reporter for chart and subchart results but [] for state results, which do not contain diagrams. To include the diagram of an applicable search result in a report, add this reporter to the report, either directly or via a Chapter or Section reporter.

Input Arguments

expand all

DiagramElementResult object, which is the output of the slreportgen.finder.DiagramElementFinder class.

Output Arguments

expand all

Diagram reporter object, returned as an object, depending on the search result. If the search result is an object that contains a diagram, such as a subsystem block or a subchart, the output is a diagram reporter. Otherwise, it is empty, []. If not empty, the diagram reporter generates a snapshot image of the diagram element.


expand all

The slrgex_sf_car model uses a Simulink Function, which is a function that uses a Simulink subsystem to compute its outputs from its inputs. This example finds the diagrams in the model and for each diagram uses an slreportgen.DiagramElementFinder object to find the Simulink Function subsystems. For each slreportgen.DiagramElementResult object returned by the finder, the example uses the Name property value as a section title and calls the getDiagramReporter method to return the subsystem diagram to add to the section.

import slreportgen.finder.*

model = "slrgex_sf_car";

rpt ="output","pdf");
chapter = Chapter();
chapter.Title = "Diagram Element Result Example";

% Find all diagrams in the model
diagFinder = DiagramFinder(model);
diagrams = find(diagFinder);
for diag = diagrams
    % Find all Simulink Function subsystems in the current diagram
    elemFinder = DiagramElementFinder(diag);
    elemFinder.Types = "slfunction";
    elems = find(elemFinder);
    for elem = elems
        section = Section("Title", ...
        % Get the diagram reporter from the result and add it to the section
        rptr = getDiagramReporter(elem);
        if ~isempty(rptr)


Introduced in R2018b