Main Content

Simulink.sdi.unregisterCursorCallback

Unregister cursor callback function

Since R2021a

    Description

    Simulink.sdi.unregisterCursorCallback(callbackID) unregisters the cursor callback function that corresponds to callbackID.

    example

    Examples

    collapse all

    You can use a Simulation Data Inspector cursor callback function to send cursor position data to an app you build using the App Designer. This example shows how to add a property to the app to store the callback ID and where to register and unregister the cursor callback. For an example of an App Designer app that uses a cursor callback, see Synchronize Cursors in the Simulation Data Inspector with an App Designer App.

    Add a callbackID property to the app object.

    properties (Access = private)
        callbackID
    end

    Define the behavior of the cursor callback function.

    methods (Access = public)
        function myCursorCallback(app,~,~)
            if isvalid(app)
                ...
            end
        end
    end

    Register the cursor callback in the app startupFcn. This example registers the same callback on the Inspect pane and the Compare pane.

    function startupFcn(app)
        app.callbackID = Simulink.sdi.registerCursorCallback(...
           @(t1,t2)myCursorCallback(app,t1,t2));
        app.callbackID(2) = Simulink.sdi.registerCursorCallback(...
           @(t1,t2)myCursorCallback(app,t1,t2),'compare');
        ...
    end

    Unregister the cursor callback in the app UIFigureCloseRequest function.

    function myAppUIFigureCloseRequest(app, event)
        Simulink.sdi.unregisterCursorCallback(app.callbackID(1));
        Simulink.sdi.unregisterCursorCallback(app.callbackID(2));
        
    end

    Input Arguments

    collapse all

    Registered callback ID, specified as a scalar. The callback ID is returned when you register the callback using the Simulink.sdi.registerCursorCallback function.

    Version History

    Introduced in R2021a