Main Content


Get navigation URL for link source or destination, requirement, test or Simulink model element

Since R2021a



    navURL = slreq.getExternalURL(myDesignItem) returns a navigation URL to a link source or destination, requirement, test or Simulink® model element specified by myDesignItem.


    The MATLAB® embedded web server must run on HTTP port 31415 to create the navigation URLs. If your MATLAB session is not configured for this HTTP port number, an error occurs when you try to create a link. Use connector.port to check the configured port number. If connector.port returns 0, use rmipref('UnsecureHttpRequests',true) to enable the embedded HTTP server. If connector.port returns a number that is not 31415, close all instances of MATLAB and reopen one instance.


    [navURL,navLabel] = slreq.getExternalURL(myDesignItem) also returns an external navigation label, navLabel.


    collapse all

    Open the CruiseRequirementsExample project. Load the crs_req requirement set.


    Find the crs_req link set. Find the link with description #9: Enable Switch Detection.

    myLinkSet = slreq.find(Type="LinkSet",Name="crs_req");
    myLink = find(myLinkSet,Description="#9: Enable Switch Detection");

    Get a navigation URL to the link source.

    navURL1 = slreq.getExternalURL(myLink.source)
    navURL1 = 

    Get a navigation URL to the link destination.

    navURL2 = slreq.getExternalURL(myLink.destination)
    navURL2 = 

    Open the CruiseRequirementsExample project. Load the crs_req_func_spec requirement set and open it in the Requirements Editor.

    rs = slreq.load("crs_req");
    rs2 ="crs_req_func_spec");

    In the Requirements Editor, in the crs_req_func_spec requirement set, select the requirement with ID #1. Get an API object for the requirement by using slreq.getCurrentObject. Then get an external navigation URL for the requirement and a label for the URL.

    req = slreq.getCurrentObject;
    [navURL1,navLabel1] = slreq.getExternalURL(req)
    navURL1 = 
    navLabel1 = 
    'Driver Switch Request Handling'

    Find a justification in the requirement set with ID #72. Get an external URL navigation URL for the justification and a label for the URL.

    jt = find(rs2,Type="Justification",ID="#72");
    [navURL2,navLabel2] = slreq.getExternalURL(jt)
    navURL2 = 
    navLabel2 = 
    'Non-functional requirement'

    Find all loaded referenced requirements. Get an external navigation URL for the third referenced requirement and a label for the URL.

    refs = find(rs,Type="Reference");
    ref = refs(3);
    [navURL3,navLabel3] = slreq.getExternalURL(ref)
    navURL3 = 
    navLabel3 = 
    'System overview'


    Clear the loaded requirement sets and link sets. Close the Requirements Editor.


    Open the CruiseRequirementsExample project. Open the crs_plant model.


    Select the Transmission subsystem and use gcb or gcbh to get a path or handle to the subsystem. Then get an external navigation URL to the subsystem and a label for the URL.

    subsys = gcb
    subsys = 
    [navURL1,navLabel1] = slreq.getExternalURL(subsys)
    navURL1 = 
    navLabel1 = 

    Look inside the shift_logic mask by clicking the icon. Select the first Stateflow® state and use sfgco to get a handle to the state. Then get an external navigation URL to the state and a label for the URL.

    firstState = sfgco
    firstState = 
      State with properties:
                         Name: 'first'
                           Id: 28
                         Path: 'crs_plant/shift_logic/gear_state'
                   SSIdNumber: 6
                    Subviewer: [1×1 Stateflow.Chart]
                  Description: ''
                  LabelString: 'first↵'
                  EntryAction: ''
                 DuringAction: ''
                   ExitAction: ''
                     OnAction: {0×1 cell}
                  MooreAction: ''
                     FontSize: 10
                    ArrowSize: 9.2240
                    TestPoint: 0
                        Chart: [1×1 Stateflow.Chart]
              BadIntersection: 0
                     Document: ''
              RequirementInfo: ''
               ExecutionOrder: 0
        ContentPreviewEnabled: 0
                          Tag: []
                   IsSubchart: 0
                    IsGrouped: 0
                        Debug: [1×1 Stateflow.StateDebug]
                 EnumTypeName: 'firstModeType'
                     Position: [50.7030 39.5270 85.3400 36.9140]
                  LoggingInfo: [1×1 Stateflow.SigLoggingInfo]
             LogStateActivity: 0
        ASLEnabledViaAncestor: 0
        IsExplicitlyCommented: 0
        IsImplicitlyCommented: 0
                  CommentText: ''
                Decomposition: 'EXCLUSIVE_OR'
                         Type: 'OR'
                 InlineOption: 'Auto'
                      Machine: [1×1 Stateflow.Machine]
                HasOutputData: 0
         OutputMonitoringMode: 'SelfActivity'
                   OutputData: []
    [navURL2,navLabel2] = slreq.getExternalURL(firstState)
    navURL2 = 
    navLabel2 = 

    Open the CruiseRequirementsExample project. Load the DriverSwRequest_Tests test file.

    tf = sltest.testmanager.load("DriverSwRequest_Tests.mldatx");

    Get the test suite in the test file.

    suite = getTestSuites(tf);

    Get the test cases in the test suite. Get an external navigation URL for the first test case and get a label for the navigation URL.

    cases = getTestCases(suite)
    cases=1×8 object
      1×8 TestCase array with properties:
    case1 = cases(1)
    case1 = 
      TestCase with properties:
                Name: 'Enable button'
            TestFile: [1×1 sltest.testmanager.TestFile]
            TestPath: 'DriverSwRequest_Tests > Unit test for DriverSwRequest > Enable button'
            TestType: 'simulation'
         RunOnTarget: {[0]}
              Parent: [1×1 sltest.testmanager.TestSuite]
        Requirements: [1×1 struct]
         Description: ''
             Enabled: 1
                Tags: [0×0 string]
    [navURL,navLabel] = slreq.getExternalURL(case1)
    navURL = 
    navLabel = 
    'Enable button'


    Clear the loaded test files.


    Input Arguments

    collapse all

    Item in MATLAB or Simulink, specified as:

    Output Arguments

    collapse all

    External navigation URL, returned as a character array.

    External navigation URL label, returned as a character array.


    • You can copy the external navigation URL to your clipboard for a:

      • Requirements Toolbox requirement, referenced requirement, or justification

      • Simulink, Stateflow, or System Composer model element

      • Simulink data dictionary entry

      Right-click one of these items in the Requirements Editor or Simulink Editor and select Copy URL to Clipboard, or select Requirements > Copy URL to Clipboard.

    Version History

    Introduced in R2021a

    See Also

    | (Simulink) | (Simulink) | (Stateflow) | (Simulink Test)