Vous êtes sur la page 1sur 6

1

EXPERIMENT NO. -- 1

AIM OF THE EXPERIMENT :
To study and know the
fundamentals, features, common commands & functions of MATLAB.

WHAT IS MATLAB? :
The MATLAB stands for matrix laboratory. MATLAB is a
software package for high performance, numerical calculation & visualization. MATLAB has build-in functions
providing excellent tool for linear algebra compilation, data analysis signal processing, optimization numerical
solution of the ordinary differential equation, also supports function for 2D & 3D graphics as well as animation.

MATLAB WINDOWES :
1. Command Window -
This is the main window characterized by the
MATLAB command prompt(>>).
2. Figure Window -
It is the output window of all graphics types of commands. This
is a separate gray window with white background colour.
3. Edit Window -
This is the window, we write, edit, create & save our programs called M-Files.

FILE TYPES :
M-Files Standard ASCII text files
MAT-Files Binary data files
FIG-Files Binary figure files
P-Types Compiled M files
MAX-Files MAT-LABS, Callable and C programs

HELP :
The most direct online help, If we know the exact name of a function we can get help on it by typing
help (function name) on the command like:

2

syntax: >>help function (enter)


HELP TOPICS :
MATLAB\General General purpose command
MATLAB\Ops Operators and special characters
MATLAB\Long Programming language constructs if you want help for long then >>help long
IF ELSE, FOR Conditionally executive statements

ROW MATRIX :.
The elements of the matrix are entered using space or commas in a line.
>> a = [1 2 3]
a= 1 2 3

COLUMN MATRIX :
The elements of the matrix are entered using semicolons in a
line.
>>b = [1; 2; 3]
b= 1
2
3

ACCESSING AN ELEMENT :
Matrix c is given as
c= 1 2 3
4 5 6

3

7 8 9
Element cij of matrix c is accessed as
>>c(2,3)
ans= 6
Any sub matrix is obtained by using range specifiers for row and column.
>>d = c(2:3, 1:3)
d= 4 5 6
7 8 9
A row or column of a matrix is detected by setting it to a null vector [ ].
>>d(:,2) = []
d= 4 6
7 9

IDENTITY MATRIX :
Command 'eye(m,n)' or 'eye(m)' returns m x n or square-m matrix
with ones on main diagonal.
>>eye(3)
ans= 1 0 0
0 1 0
0 0 1

ZERO MATRIX :
Command 'zeros(m)' returns a square-m matrix with all elements zero.
>>zeros(2)
ans= 0 0
0 0


4

ONE MATRIX :
Command 'ones(m)' returns square-m matrix with all elements one.

>>ones(2)
ans= 1 1
1 1

RANDOM MATRIX :
Random matrix can be created given below:
>>a = [ones(3), zeros(3,2) ; zeros(2,3), 4*eye(2)]
a= 1 1 1 0 0
1 1 1 0 0
1 1 1 0 0
0 0 0 4 0
0 0 0 0 4

DIAGONAL MATRIX :
The command 'diag(b)' extracts the diagonal elements of
matrix-b as a vector.
Matrix b= 1 2 3
4 5 6
7 8 9
>>diag(b)
ans= 1
5
9


5

LOOKFOR :
Look for is a keyword search function. If we are looking for a function use look for
keyword to get a list of function with the string keyword in their description.
example: >>lookfor determinant

CONCLUSION :
From the above experiment we have studied the fundamental features,
common commands and function of MATLAB.
SUBMITTED BY-
Pradip Kumar Mishra
Regd no.1221217045

















6

Vous aimerez peut-être aussi