KB01: Useful MATLAB Commands



A few Important Commands

demo Run MATLAB's built-in demonstrations  
clc Clear the Command Window  
clf Clear the contents of the current figure window  
clear Clear the variables in the workspace  
CTRL + C Abort the running program, returns a command prompt  
diary Keep track of everything done in the MATLAB session  



General Purpose Commands

General Purpose Commands

Operators and Special Characters

+ Plus; addition operator  
- Minus; subtraction operator  
* Scalar and matrix multiplication operator  
.* Array multiplication operator  
^ Scalar and matrix exponentiation operator  
.^ Array exponentiation operator  
\ Left-division operator  
/ Right-division operator  
.\ Array left-division operator  
./ Array right-division operator  
: Colon; generates regularly spaced elements and represents an entire row or column  
( ) Parentheses; encloses function arguments and array indices; overrides precedence  
[ ] Brackets; enclosures array elements  
. Decimal point  
... Ellipsis; line-continuation operator  
, Comma; separates statements and elements in a row  
; Semicolon; separates columns and suppresses display  
% Percent sign; designates a comment and specifies formatting  
_ Quote sign and transpose operator  
._ Nonconjugated transpose operator  
= Assignment (replacement) operator  


Commands for Managing a Session

clc Clears Command window
clear Removes variables from memory  
exist Checks for the existence of file or variable  
global Declares variables to be globa  
help Searches for a help topic  
lookfor Searches help entries for a keyword  
quit Stops MATLAB  
who Lists current variables  
whos Lists current variables (long display)  


Special Variables and Constants

ans Most recent answer
eps Accuracy of floating-point precision  
i, j The imaginary unit \(\sqrt { - 1} \)  
Inf Infinity  
NaN Undefined numerical result (not a number)  
pi The number π  


System and File Command

cd Changes current directory
date Displays current date  
delete Deletes a file  
diary Switches on/off diary file recording  
dir Lists all files in the current directory  
load Loads workspace variables from a file  
path Displays search path  
pwd Displays current directory  
save Saves workspace variables in a file  
type Displays contents of a file  
what Lists all MATLAB files in the current directory  
wklread Read .wkl spreadsheet file  







© 2024 Air Supply Information Center (Air Supply BBS)