Enter Multiline Labels in States and Transitions

The following state uses a multiline label:

There are two ways to enter multiline labels for states and transitions. In the following examples, sA is a handle to the State object in the chart for state A:

  • Use the MATLAB® function sprintf:

    str = sprintf('A\nen: entryA()\ndu: duringA()\nex: exitA()');
    sA.LabelString = str;

    In this example, the escape sequence \n inserts a new line into an expression.

  • Use a concatenated text expression:

    str = ['A',10,'entr: entryA()',10,'du: duringA()',...
        10,'ex: exitA()'];
    sA.LabelString = str;

    In this example, the ASCII equivalent of a new line, the integer 10, inserts new lines into a concatenated text expression.

Related Topics