Main Content


Provide tracing information as graph for structure analysis


An sltrace.Graph object stores tracing information generated by the sltrace function.


You can create sltrace.Graph object using the sltrace function.


expand all

Tracing graph with edges and nodes, returned as a digraph object. A node in the graph is decided by a block port on the tracing path and shown as 'NodeIndex'. For each node, TraceGraph.Nodes provides a table with more details, including Block, PortNumber and PortType. If 'BlockPath' is set to 'on' in sltrace, then the Block column of the TraceGraph.Nodes table will be shown as Simulink.BlockPath.

TraceGraph.Edges shows a table that contains the EndNodes of the digraph object, and the Segments between them. Segments is an array of segment handles that are connected together to form a line between two blocks. If the EndNodes belong to the same block, their Segments is marked as 'Internal'. If the end nodes are from connectionless block pairs, such as the pair formed by 'From' and 'Goto', then their Segments is marked as 'Hidden'.

Blocks on tracing path, specified as an array of block handles or Simulink.BlockPath objects. If tracing in the direction of source, source blocks are returned in g.SrcBlocks. If tracing in the direction of the destination, destination blocks are returned in g.DstBlocks.

Object Functions

highlightHighlight tracing results
removeHighlightRemove highlighted tracing results


collapse all

This example shows how to trace from the first inport of the block vdp/x1 to all sources.

G = sltrace('vdp/x1', 'Source','Port', 1, 'TraceAll','on');

Highlight the tracing results and plot the trace graph.



Figure contains an axes object. The axes object contains an object of type graphplot.

Highlight the block vdp/Scope and the line connecting to the inport of vdp/Scope.

bh = get_param('vdp/Scope','Handle');
inportH = get_param('vdp/Scope','PortHandles').Inport;
lh = get_param(inportH,'line');
highlight(G,[bh, lh])

Remove the highlighting.


Version History

Introduced in R2021b