## MATLAB Operators and Special Characters

This page contains a comprehensive listing of all MATLAB® operators, symbols, and special characters.

### Arithmetic Operators

SymbolRole
`+`

`+A`

Unary plus

`-`

Subtraction

`-A`

Unary minus

`.*`

Element-wise multiplication

`*`

Matrix multiplication

`./`

Element-wise right division

`/`

Matrix right division

`.\`

Element-wise left division

`\`

Matrix left division

(also known as backslash)

`.^`

Element-wise power

`^`

Matrix power

`.'`

Transpose

`'`

Complex conjugate transpose

### Relational Operators

SymbolRole
`==`

Equal to

The `=` character is for assignment, whereas the `==` character is for comparing the elements in two arrays.

`~=`

Not equal to

`>`

Greater than

`>=`

Greater than or equal to

`<`

Less than

`<=`

Less than or equal to

### Logical Operators

SymbolRole
`&`

Find logical AND

`|`

Find logical OR

`&&`

Find logical AND (with short-circuiting)

`||`

Find logical OR (with short-circuiting)

`~`

Find logical NOT

### Special Characters

SymbolRole
`@`

Create anonymous functions and function handles, call superclass methods

`.`

Decimal point, element-wise operations, indexing

`...`

Line continuation

`,`

Separate row elements in an array, array subscripts, function input and output arguments, commands entered on the same line

`:`

Vector creation, for-loop iteration, indexing

`;`

Separate rows in an array creation command, suppress output of a line of code

`( )`

Operator precedence, function argument enclosure, indexing

`[ ]`

Array construction and concatenation, empty matrix creation, element deletion, multiple output argument assignment

`{ }`

Create cell array, indexing

`%`

`{% %}`

Block of comments that extend beyond one line

`!`

Issue operating system command

`?`

Retrieve metaclass information for class name

`''`

Create character array

`""`

Create string

`~`

Represent logical NOT, suppress specific input or output arguments.

`=`

Variable creation and indexing assignment.

The `=` character is for assignment, whereas the `==` character is for comparing the elements in two arrays.

```< &```

Specify one or more superclasses in a class definition.

`.?`

Specify the fields of a name-value structure as the names of all writeable properties of the class.

### String and Character Formatting

Some special characters can only be used in the text of a character vector or string. You can use these special characters to insert new lines or carriage returns, specify folder paths, and more.

Use the special characters in this table to specify a folder path using a character vector or string.

 `/``\` Name: Slash and BackslashUses: File or folder path separationDescription: In addition to their use as mathematical operators, the slash and backslash characters separate the elements of a path or folder. On Microsoft® Windows® based systems, both slash and backslash have the same effect. On The Open Group UNIX® based systems, you must use slash only.ExamplesOn a Windows system, you can use either backslash or slash:```dir([matlabroot '\toolbox\matlab\elmat\shiftdim.m']) dir([matlabroot '/toolbox/matlab/elmat/shiftdim.m']) ```On a UNIX system, use only the forward slash:```dir([matlabroot '/toolbox/matlab/elmat/shiftdim.m']) ``` `..` Name: Dot dotUses: Parent folderDescription: Two dots in succession refers to the parent of the current folder. Use this character to specify folder paths relative to the current folder.ExamplesTo go up two levels in the folder tree and down into the `test` folder, use:`cd ..\..\test`More Information `cd` `*` Name: AsteriskUses: Wildcard characterDescription: In addition to being the symbol for matrix multiplication, the asterisk `*` is used as a wildcard character.Wildcards are generally used in file operations that act on multiple files or folders. MATLAB matches all characters in the name exactly except for the wildcard character `*`, which can match any one or more characters.ExamplesLocate all files with names that start with `january_` and have a `.mat` file extension:`dir('january_*.mat')` `@` Name: At symbolUses: Class folder indicatorDescription: An `@` sign indicates the name of a class folder.ExamplesRefer to a class folder:`\@myClass\get.m`More Information `+` Name: PlusUses: Namespace directory indicatorDescription: A `+` sign indicates the name of a namespace folder.ExamplesNamespace folders always begin with the `+` character:```+myfolder +myfolder/pkfcn.m % a namespace function +myfolder/@myClass % class folder in a namespace```More Information

There are certain special characters that you cannot enter as ordinary text. Instead, you must use unique character sequences to represent them. Use the symbols in this table to format strings and character vectors on their own or in conjunction with formatting functions like `compose`, `sprintf`, and `error`. For more information, see Formatting Text.

SymbolEffect on Text
`''`

Single quotation mark

`%%`

Single percent sign

`\\`

Single backslash

`\a`

Alarm

`\b`

Backspace

`\f`

Form feed

`\n`

New line

`\r`

Carriage return

`\t`

Horizontal tab

`\v`

Vertical tab

`\xN`

Hexadecimal number, `N`

`\N`

Octal number, `N`