Enter Multiline Labels

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: entrA()\ndu: duriA()\nex: exitA()');
    sA.LabelString = str;
    

    In this example, the escape sequence \n inserts carriage returns into a string expression.

  • Use a concatenated string expression:

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

    In this example, the ASCII equivalent of a carriage return, the integer 10, inserts carriage returns into a concatenated string expression.

Was this topic helpful?