Main Content

sltrace

Trace signals in a model

    Description

    g = sltrace(p) traces a signal oriented from the port p and stores the results in the sltrace.Graph object g.

    g = sltrace(block, direction) traces a signal oriented from the block toward the direction, and stores the results in g. The argument direction includes ‘source’ and ‘destination’.

    example

    g = sltrace(___, Name,Value) traces a signal using one or more Name,Value arguments.

    Examples

    collapse all

    Trace from the first inport of 'vdp/Scope' to all sources.

    vdp
    g = sltrace('vdp/Scope', 'Source', 'Port', 1, 'TraceAll','on')
    g = 
    
      Graph with properties:
    
         SrcBlocks: [2.0001 5.0001 6.0001 7.0001 9.0001 10.0001 11.0001 12.0001 13.0001]
         DstBlocks: []
         TraceGraph: [1×1 digraph]
    

    Trace from the second inport handle of 'vdp/Sum' to Stop block 'vdp/Product'and display the results in Simulink.BlockPath format.

    bPort = get_param('vdp/Sum', 'PortHandles').Inport(2);
    G = sltrace(bPort, 'Stop', 'vdp/Product', 'BlockPath','On');
     

    Input Arguments

    collapse all

    Block port where tracing begins, specified as a port handle.

    Block where tracing begins, specified as a block name, block handle, or as Simulink.BlockPath object.

    Direction of traced signal, specified as either 'Source' or 'Destination'.

    Data Types: char | string

    Name-Value Arguments

    Specify optional Name,Value arguments, where Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

    Example: 'TraceAll','on','BlockPath','on'

    Trace to all sources or destinations, specified as 'off' or 'on'. By default, tracing stops at the first non-virtual block. Set this argument to 'on' to trace to all sources or destinations.

    Example: 'TraceAll','on'

    Block where tracing stops, specified as a block name, block handle, or as Simulink.BlockPath object. If the block where tracing stops is not on the tracing path, sltrace traces to all blocks.

    Example: 'Stop','vdp/Sum'

    Port where tracing begins, specified as a real positive scalar. When tracing from a block with multiple inports or outports, you can enable the 'Port' option to select a specific port to trace from. Without enabling 'Port', sltrace will trace from all inports or outports. You can omit 'Port' when tracing from a block port handle.

    Example: 'Port','2'

    Data Types: double | single

    Bus element where tracing begins. sltrace supports tracing to the source from a Bus Creator block and tracing to a destination from a Bus Selector block. You do not need to specify this parameter if tracing from block port handle p.

    Example: 'Element','b'

    Data Types: char | string

    Option to return tracing information as Simulink.BlockPath object, specified as 'off' or 'on'. If there are multiple instances of a referenced model, set 'BlockPath' to 'on' to obtain accurate tracing results for different model instances.

    Output Arguments

    collapse all

    Tracing result, returned as a sltrace.Graph object.

    Introduced in R2021b