MATLAB Commands

MATLAB Commands

MATLAB (stands for matrix laboratory) is a high-level programming environment for scientific calculation, and it provides functions more efficiently than other programming languages. In addition, it has many in-build modules and integration with Simulink, which helps in complex computation.

MATLAB commands are very helpful to users to establish connection with the application. Using a command-line interface, the user can interact with the software using MATLAB's various commands.

The primary purpose of MATLAB commands is to work with the system like import/export data, loading files to carry out the application functions.

It provides various commands to serve different purposes; for example, to clear the screen, we use the command ">>clear."

Let us look into some basic MATLAB commands

clearIt clears variables from the memory
whatMATLAB files are listed in the current directory
pwdCurrent directory is displayed
dateCurrent date is displayed
helpJust type this command at command window if you want any kind of guide or help
whoThis command helps to list the current variable
typeContent of a file is displayed
existExistence of a variable is checked with the help of this command
clcCommand window gets cleared
globalA variable is declared as global by using this command
dispContent of array or string is displayed  
fscanfFormatted data from a file is read.
inputTo prompt for input
formatScreen-display format
fprintfWrites formatted files to screen or file
;Screen printing
quitExits from MATLAB
lookforTo help entries for keyword

Let us execute some of the above-mentioned commands.

Commands like ‘whos’, ‘date’, ‘what’ are executed.
MATLAB Commands
Commands like ‘pwd’, ‘help’, ‘disp’, ‘who’ are executed.
MATLAB Commands

Now let us look into some intermediate and advance MATALB commands

Commands related to files and directory information

dirContents of current directory are listed out.
rmdirTo remove a directory
mkdirTo create new directory
cdTo change directory
copyfileTo copy a file
editpathSearch path changes
IsCurrent file contents are listed
pathMATLAB search path (sets or gets)
deleteTo Delete file
diaryTo save the text generated in MATLAB session
!Thiscommand provide access to Operating system.
wklreadThis command read .wk1 spreadsheet file.

Any kind of help regarding the user manual or procedure to check out any features of the software can be fetched with the help of these on-line commands.

helpTo provide basic help info
helpdeskBrowser based help is provided
demoTo run demo program
docWeb HTML documentation
infoMATLAB information is displayed
whatsnewReadMe files are displayed
echoScript file echo command
homeTo send cursor home

Let us execute some of the above-mentioned commands.

Commands like ‘helpdesk’, ‘demo’, ‘doc’ are executed.
MATLAB Commands
MATLAB Commands
MATLAB Commands

Commands for general use

General use in the sense to fetch basic information of our computer like date and time or type of computer we use. Let us look few of them mentioned below.

computerReturns which type of computer your using
clockVector format of clock time and data
morePaged output is controlled
verLicense and version of MATLAB data is displayed
benchTo provides benchmarks
^c(Control-c)To locally abort
startupTo execute M-file
ticTo start stopwatch
tocTo read the time of stopwatch
etimeTo find elapsed time function
cputimeTo find elapsed CPU time
matlabarcMaster start-up file

Let us execute some of the above-mentioned commands.

Commands like ‘computer’, ‘clock’, ‘ver’, ‘bench’, ‘tic’, ‘tac’, ‘cputime’ are executed.
MATLAB Commands
Commands ‘ver’ and ‘bench’ are executed.
MATLAB Commands
Commands  ‘tic’, ‘tac’, ‘cputime’ are executed.
MATLAB Commands

Commands on mathematical computations

Here are few MATLAB commands which are especially programmed for carrying out various mathematical computations like array manipulation, solving linear algebra, integration, polynomial, calculus, elementary math, etc.

Commands for Matrix arithmetic
eyeAn identity matrix is created
onesArray of ones is created
zerosArray of zeros is created
dotTo generate Dot product of two matrices
crossTo generate cross product of two matrices
Commands for array operations
catTo concatenate two arrays
lengthTo calculate no. of elements in the array
minMinimum value of array is returned
maxMaximum value of array is returned
Commands for matrix for linear equations
rankReturns the rank of a matrix
detDeterminant of the matrix is returned
inv  To return inverse of a matrix.
Commands for polynomial
poly2sym(vector)This helps to convert vector to symbolic polynomial.
poly2sym(vector,’v’)This is also similar to poly2sym(vector).
Commands for strings
findstrTo find start index in a given string.
strcmp  To compare two given strings, returns 1 if match is found or else it returns 0.
linsolve()To solve linear expressions.
contour()To solve linear expressions.