Main Content


Open and highlight line range in MATLAB Editor

Since R2022b




    show(lr) opens the file associated with the line range lr in the MATLAB® Editor and highlights the line range.


    collapse all

    This example shows how to create an slreq.TextRange object and link it to a requirement.

    Create an slreq.TextRange object that corresponds to line numbers 1 and 2 in the myAdd function.

    lineRange = slreq.createTextRange("myAdd.m",[1 2]);

    View the slreq.TextRange object in the MATLAB® Editor.


    Load the myAddRequirements requirement set.

    rs = slreq.load("myAddRequirements");

    Get a handle to the requirement with the summary Add u and v.

    req = find(rs,Summary="Add u and v");

    Create a link from the slreq.TextRange object to the requirement.

    myLink = slreq.createLink(lineRange,req);

    Input Arguments

    collapse all

    Line range, specified as an slreq.TextRange object.

    Version History

    Introduced in R2022b