Main Content

findbindings

Find bindings between objects

Since R2024a

    Description

    example

    b = findbindings(obj) finds all bindings where obj is either the source or destination of the binding. The function returns the bindings as an array of Binding objects.

    b = findbindings(obj,"source") finds all bindings where obj is the source of the binding.

    example

    b = findbindings(obj,"destination") finds all bindings where obj is the destination of the binding.

    Examples

    collapse all

    Create a spinner in a UI figure.

    fig = uifigure;
    spn = uispinner(fig);

    Create a Simulation object that represents a simulation of the bouncingBall model and load the model.

    s = simulation('bouncingBall',LoadModel=true);

    Connect the spinner to a model variable by creating a binding.

    vars = s.TunableVariables;
    varname = "K:bouncingBall";
    bind(spn,"Value",vars,varname);

    Find all bindings for which the spinner is either a source or a destination.

    b1 = findbindings(spn)
    b1 = 
      Binding with properties:
    
                      Source: [1x1 Spinner]
             SourceParameter: 'Value'
                 Destination: [1x1 simulink.sim.Variables]
        DestinationParameter: 'K:bouncingBall'
                     Enabled: 1
    
    

    Find all bindings for which the spinner is a destination. In this case, there are none, so findbindings returns an empty array of Binding objects.

    b2 = findbindings(spn,"destination")
    b2 = 
    
      1x0 Binding array with properties:
    
        Source
        SourceParameter
        Destination
        DestinationParameter
        Enabled
    

    Input Arguments

    collapse all

    Source or destination of a binding, specified as one of these objects:

    • UI component

    • Signals object associated with the LoggedSignals property of a Simulation object

    • Variables object associated with the TunableVariables property of a Simulation object

    Version History

    Introduced in R2024a

    See Also

    Functions

    Objects