COMMANDS:-                        

MATLAB is an interactive program for numerical computation and visualization. You can enter a command by typing at the MATLAB prompt ">>" on the command window. In this section, we will discuss some general MATLAB commands which are used in a daily basis.

Commands for working with the system:-

In  MATLAB command library there are various useful commands for working with the system, like saving this the current work in the workspace as a file and loading the file later. It also provides various commands for displaying date, listing files in the directory, displaying current directory, etc.
Some commonly used system-related commands:-

Command

Purpose

cd
Changes current directory.
date
Displays the 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 within the current directory.
wklread
Reads .wk1 spreadsheet file.

Commands for Managing a Session:-

MATLAB provides various commands for managing a session. 
The following table provides all such commands:-

Command

Purpose

clc
Clears command window.
clear
Removes variables from memory.
exist
Checks for existence of file or variable.
global
Declares variables to be global.
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.

Commands for Input and Output:-

In  MATLAB command library there are some commands which are related to input and output:-

Command

Purpose

disp
Displays contents of an array or string.
fscanf
Read formatted data from a file.
format
Controls screen-display format.
fprintf
Performs formatted writes to screen or file.
input
Displays prompts and waits for input.
;
Suppresses screen printing.
The fscanf and fprintf commands be like C scanf and printf functions. 
They support the following format codes:-

Format Specifier

Purpose

%s
Format as a string.
%d
Format as an integer.
%f
Format as a floating-point value.
%e
Format as a floating-point scientific notation.
%g
Format within the most compact form:- (%f  or %e)
\n
Insert a new line 
\t
Insert a tab
Commands for Vector, Matrix and Array:-
Table of commands used for working with arrays, matrices and vectors −

Command

Purpose

cat
Concatenates arrays.
find
Finds indices of nonzero elements.
length
Computes the number of elements.
linspace
Creates regularly spaced vector.
logspace
Creates logarithmically spaced vector.
max
Returns largest element.
min
Returns smallest element.
prod
Product of each column.
reshape
Changes size.
size
Computes array size.
sort
Sorts each column.
sum
Sums each column.
eye
Creates an identity matrix.
ones
Creates an array of ones.
zeros
Creates an array of zeros.
cross
Computes matrix cross products.
dot
Computes matrix dot products.
det
Computes determinant of an array.
inv
Computes the inverse of a matrix.
pinv
Computes pseudoinverse of a matrix.
rank
Computes rank of a matrix.
rref
Computes reduced row echelon form.
cell
Creates cell array.
celldisp
Displays cell array.
cellplot
Displays a graphical representation of the cell array.
num2cell
Converts numeric array to cell array.
deal
Matches input and output lists.
iscell
Identifies cell array.
Commands for Plotting:-
MATLAB provides numerous commands for plotting graphs. 
Table of commonly used commands for plotting:-

Command

Purpose

axis
Sets axis limits.
fplot
Intelligent plotting of functions.
grid
Displays gridlines.
plot
Generates XY plot.
print
saves plot to a file.
title
Puts text at top of plot.
xlabel
Adds text label to x-axis.
ylabel
Adds text label to y-axis.
axes
Creates axes objects.
close
Closes the current plot.
close all
Closes all plots.
figure
Opens a new figure window.
gtext
Enables label placement by mouse.
hold
Freezes current plot.
legend
Legend placement by mouse.
refresh
Redraws current figure window.
set
Specifies properties of objects such as axes.
subplot
Creates plots in subwindows.
text
Places string in figure.
bar
Creates bar chart.
loglog
Creates log-log plot.
polar
Creates polar plot.
semilogx
Creates semilog plot. logarithmic abscissa.
semilogy
Creates semilog plot. logarithmic ordinate.
stairs
Creates stairs plot.
stem
Creates stem plot.

contact-form

Post a Comment

If you have any doubts regarding this topic...
feel free to ask...

Previous Post Next Post