MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Symbol Symbol Name Role Description Examples


; Semicolon



  • Signify end of row

  • Suppress output of code line


Use semicolons to separate rows in an array creation command, or to suppress the output display of
a line of code.


  • vertcat


Separate rows to create an array:

A = [12,13; 14,15]

Suppress code output:

Y = max(A);

Separate multiple commands on a single line (suppressing output):

A = 12.5; B = 42.7, C = 1.25;
B =
42.7000

( ) Parentheses



  • Operator precedence

  • Function argument enclosure

  • Indexing


Use parentheses to specify precedence of operations, enclose function input arguments, and index
into an array.


  • “Operator Precedence” on page 2-29

  • “Array Indexing”


Precedence of operations:

(A.*(B./C)) - D

Function argument enclosure:

plot(X,Y,'r*')
C = union(A,B)

Indexing:

A(3,:)
A(1,2)
A(1:5,1)

MATLAB Operators and Special Characters
Free download pdf