MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Symbol Symbol Name Role Description Examples


%{ %}


Percent curly
bracket
Block comments

The %{ and %} symbols enclose a block of comments that extend beyond one line.

NoteWith the exception of whitespace characters, the %{ and %} operators must appear alone on
the lines that immediately precede and follow the block of help text. Do not include any other text
on these lines.


  • “Add Comments to Programs” on page 18-4


Enclose any multiline comments with percent followed by an opening or closing brace:

%{
The purpose of this routine is to compute
the value of ...
%}

! Exclamation point Operating system command


The exclamation point precedes operating system commands that you want to execute from within
MATLAB.


  • “Shell Escape Function Example”


Not available in MATLAB Online™.

The exclamation point initiates a shell escape function. Such a function is to be performed directly by the
operating system:

!rmdir oldtests

? Question mark Metaclass for MATLAB class


The question mark retrieves the meta.class object for a particular class name. The? operator
works only with a class name, not an object.


  • metaclass


Retrieve the meta.class object for class inputParser:

?inputParser

'' Single quotes Character array constructor


Use single quotes to create character vectors that have class char.


  • “Represent Text with Character and String Arrays” on page 6-2


Create a character vector:

chr = 'Hello, world'

"" Double quotes String constructor


Use double quotes to create string scalars that have class string.


  • “Represent Text with Character and String Arrays” on page 6-2


Create a string scalar:

S = "Hello, world"

N/A Space character Separator
Use the space character to separate row elements in an array constructor, or the values returned by
a function. In these contexts, the space character and comma are equivalent.


Separate row elements to create an array:

% These statements are equivalent
A = [12 13; 14 15]
A = [12,13; 14,15]

Separate output arguments in function calls:

% These statements are equivalent
[Y I] = max(A)
[Y,I] = max(A)

MATLAB Operators and Special Characters
Free download pdf