Scientific Computing & Visualization
Help Contact
About Accounts Computation Visualization Documentation Services

Introduction to MATLAB

Special Characters

There are a number of special reserved characters used in MATLAB for various purposes. Some of these are used as arithmetic operators, namely, +, -, *, / and \. While others perform a multitude of purposes:

bullet % -- anything after % (and until end of line) is treated as comments, e.g.,
>> x = 1:2:9; % x = [1 3 5 7 9];
bullet ! -- prepend it to a unix command to execute, e.g.,
>> !ls -l
bullet ; -- delimits statements; suppresses screen output, e.g.,
>> x = 1:2:9; y = 2:10; % two statements on the same line
bullet ... -- statement continuation, e.g.,
>> x = [ 1 3 5 ...
7 9]; % x = [1 3 5 7 9] split into 2 lines
bullet : -- range delimiter, e.g.,
>> x = [1:2:9]; % x=[1,3,5,7,9]
bullet ' -- matrix transposition, e.g.,
>> x = [1:2:9]'; % x changed from row vector to column vector
If the vector/matrix is complex, "'" results in complex conjugation and matrix transposition.
bullet , -- command delimiter, e.g.,
>> x = [1:2:9], y = [1:9] % two statements on the same line
bullet . -- precede an arithmetic operator to perform an elemental operation, instead of matrix operation, e.g.,
>> x = 3:3:9    

x =     

     3     6     9    
     
>> y = 3*ones(3,1)'   

y =    
     3     3     3    
     
>> z =x./y    

z =    
     1     2     3  
bullet * -- "wild card", e.g.,
>> clear A* % clears all variables that start with A.

Note that many of these characters have multiple functionalities (function overloading) depending on the context, e.g., "*" is used for scalar multiply, matrix multiply and "wild card" as seen above.

bullet up left
Documentation
Boston University
Boston University
 
OIT | CCS | July 7, 2009  
Scientific Computing & Visualization Boston University home page Boston University home page