Like all programming languages, MATLAB has a set of special characters for interpreting the program. These characters are reserved for the system and cannot be used by the programming user to assign names to variables, functions, or other types of definitions that can be made. These special characters include arithmetic operators, logical operators, etc. Due to its length, in this article, we will only explain in detail what belongs to the special characters and leave the operators to another article.

List of MATLAB special characters, meaning and application

Below we list each MATLAB special characters and explain their usage and meaning with a brief example.

MATLAB Special character @ (At symbol)

This symbol is used when creating a function. To do this, the function name must be declared after the “@” symbol.

In the case of an anonymous function.

MATLAB Special character . (Dot)

The dot separates the whole and fractional parts in decimal values.

The dot character also allows you to access the fields of a structure

This symbol is also used to access the properties and methods of an object.

Special character … (Dot dot dot or ellipsis)

At the end of a line, this symbol indicates that the current command continues on the next line.

command…

continuation of current command

MATLAB Special character , (Comma)

This character is used to separate row elements of array subscripts.

q = [ 1, 2, 3, 4; 5, 6, 7, 8 ]

Also, this character is used to separate the different input arguments in a function.

And to separate the different output arguments in a function

MATLAB Special character : (Colon)

This character is used for creating vectors.

Also, the colon is used to define the limit in a “for” loop.

Index a range of elements in a specified dimension:

Assign new elements to an array:

x = [ 1, 2, 3, 4;

5, 6, 7, 8;

1, 2, 3, 4 ]

x (:) = 1: 12

MATLAB Special character ; (Semicolon)

This character is used to separate the rows in the creation of a matrix

x = [ 1, 2, 3, 4;

5, 6, 7, 8;

1, 2, 3, 4]

It is also used to suppress the output of the current command.

Or to several separate commands written on a single line

MATLAB Special character ( ) (Parentheses)

These characters are used to enclose the input arguments of a function.

Also, these special characters are used for array indexing.

They are also used in mathematical operations in operator precedence.

MATLAB Special character [ ] (Square brackets)

These special characters are used for the creation of matrices and vectors.

m = [ 1, 2, 3, 4; 5, 6, 7, 8; 1, 2, 3, 4]

v = [1, 2, 3, 4]

Square bracket to capture more than one input argument in a function.

Square brackets for the creation of an empty array.

Square bracket to add a new bottom row to an array.

a = magic(5);

a = [a; 4, 5, 8, 3, 2]

Square bracket to remove a matrix column:

a = magic(5);

a (:,1) = []

MATLAB Special character { } (Curly braces )

These special characters are used in creating cell arrays.

s1 = {‘ a ‘,‘ z ‘,‘ h ‘,‘ y ‘}

MATLAB Special character % (Percent )

The percent character is used to make comments. Everything written after this character on the current line is not considered code by MATLAB and is only useful as programmer annotation.

% This is a comment, it is not part of the program

MATLAB Special character % { %} (Percent curly bracket)

This character set is used to make comments that extend over more than one line. The %{ and %} operators must appear alone on the lines immediately preceding and following the text block as shown below.

%{

This is a comment.

Everything enclosed within

these curly braces are considered

commentary by MATLAB.

%}

MATLAB Special character ? (Question Mark )

This character retrieves the meta.class object. This operator only works with a class name, not an object.

MATLAB Special character ‘ ‘ (Single quotes )

These characters are used to create character vectors with a class of char.

MATLAB Special character “ “ (Double quotes )

These characters are used to create strings that have a class of strings.

MATLAB Special character “Space“

This character represents a logical NOT.

Also, this character is used to suppress specific input or output arguments of a function.

MATLAB Special character = (Equal )

This character assigns values to a variable.

The space character is used like commas to separate row elements in the construction of an array.

Also, like commas, it is used to separate the values returned by a function.

MATLAB Special character ~ (Tilde )

Also, to store the elements of a in the variable b.

MATLAB Special character < & (Left angle bracket and ampersand )

This character set is used to specify superclasses.

classdef MyClass < MySuperclass

And in the definition of a class that derives from a superclass:

classdef MyClass < MySuperclass1 & MySuperclass2 & …

MATLAB Special character .? (Dot question mark )

This character set specifies the name-value structure fields.

In this case, the field names of the propArgs structure are specified as write properties of the matlab.graphics.primitive.Line class.

function f(propArgs)

arguments

propArgs.? matlab.graphics.primitive.Line

end

end

Conclusion

In this article, we have shown you the list of MATLAB special characters and explained the meaning of each character with a short example. This programming language also has relational, arithmetic, logical operators, and escape characters, which are covered in our other MATLAB articles. We hope you found this MATLAB article useful. For more tips and information, see other Linux Hint articles.

About the author

<img alt="" data-lazy-src="https://secure.gravatar.com/avatar/b26dd689ed4af67c9613eb44788137d9?s=112&r=g" data-lazy- height="112" src="data:image/svg xml,” width=”112″>

Julio Cesar

Julio Cesar is a 42 years old programmer with 8 years of experience in embedded systems development, 6 years developing firmware for user interfaces in C and C . Additionally he has 2 years of experience developing scripts for network devices and 3 years as developer of high frequency PCB (Printed Circuit Board).