newline

The newline character, char(10).

Category: Language Fundamentals > Data Types

Syntax

c = newline

Returns the newline character.

Description

newline is a readable way to put a line break inside text without writing char(10) or relying on escape sequences. Escapes such as \n only work in the format of sprintf and fprintf, not in ordinary quoted strings, so newline is the way to build multi-line text by concatenation.

Output arguments

c
A 1-by-1 char array holding code 10.

Example

s = "first" + newline + "second";
splitlines(s)
double(newline)
Output
ans = 2×1 string array

    "first"
    "second"
ans = 10

See also

splitlines sprintf char strsplit join