MATLAB Commands

MATLAB is an interactive program for numerical computing and data visualization. We can enter a command by typing it at the MATLAB prompt '>>' on the Command Window.

In this topic, we will provide lists of frequently used general MATLAB commands.

On-Line help

CommandsPurpose
helplists topics on which help is available
helpwinopens the interactive help window
helpdeskOpens the web-browser-based help facility
help topicprovide help on the topic
lookfor stringlists help topics containing a string
demoruns the demo program
lookforKeyword search for help
docOnline HTML documentation
whatsnewDisplay ReadMe files
infoInfo about MATLAB
syntaxHelp on command syntax
whyGive a philosophical device
formatSet screen output format
moreControl paged screen output
homeSend cursor home
echoEcho commands in the script file
↑,↓Recall previous commands
globalDeclare variables to be global

Variable and Workspace Information

CommandsPurpose
wholists variables currently in the workspace
whoslists variables directly in the workspace with their size
whatlists M-, Mat-, and Mex directories on the disk
clearclear the workspace, and all variables are removed
clear x, y, zclear only variables x, y, and z.
clear allClears all variables and function from workspace
mlock funlocks function fun so that clear cannot delete it
munlock fununlocks functions fun so that clear cannot remove it
clcclears command window, cursor shift to the top
homescrolls the command window, cursor moves to the top
clfclear figure window
loadLoad variable from file
saveSave variable in Mat-file
lengthLength of a vector
sizeSize of a matrix
packConsolidate memory space
dispDisplay text or matrix

Working with Files and Directory Information

CommandsPurpose
pwdshows the current working directory
cdchanges the current working directory
dirlists contents of the current directory
lslists contents of the current files, same as dir
pathgets or sets MATLAB search path
editpathmodifies MATLAB search path
copyfilecopies a file
mkdircreates a new directory
rmdirRemove directory
deleteDelete file
diarySave text of MATLAB session
typeShow contents of the file
!Access operating system
pathList accessible directories
whatLists all MATLAB data in the current directory.
wklreadReads .wk1 spreadsheet file.

General Information

CommandsPurpose
computertells you the computer type you are using
clockgives you wall clock time and date as a vector
datetells you the date as a string
morecontrol the paged output according to the screen size
vergives the license and the MATLAB version data
benchbenchmarks our computer on running MATLAB compared to other devices

Start and Exist

CommandsPurpose
^c(Control-c)local abort, kills the current command execution
matlabarcMaster start-up file
startupM-file executed at start-up
quitQuit MATLAB
exitsame as quit

Time and Date

CommandsPurpose
clockWall clock time
cputimeElapsed CPU time
dateDate, month, year
etimeElapsed time function
ticStart stopwatch timer
tocRead stopwatch timer