0% found this document useful (0 votes)
20 views

Matlab: MATLAB (Matrix Laboratory) Is A

MATLAB is a numerical computing environment and programming language. It allows matrix manipulations, plotting of functions and data, implementation of algorithms, and interfacing with other languages. The document then discusses working with matrices in MATLAB, including declaring matrices, different types of matrices like row, column, square, and identity matrices. It also covers various operations that can be performed on matrices such as addition, subtraction, multiplication, inverse, determinant, and scalar multiplication.

Uploaded by

Risalatshamoa
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Matlab: MATLAB (Matrix Laboratory) Is A

MATLAB is a numerical computing environment and programming language. It allows matrix manipulations, plotting of functions and data, implementation of algorithms, and interfacing with other languages. The document then discusses working with matrices in MATLAB, including declaring matrices, different types of matrices like row, column, square, and identity matrices. It also covers various operations that can be performed on matrices such as addition, subtraction, multiplication, inverse, determinant, and scalar multiplication.

Uploaded by

Risalatshamoa
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 7

MATLAB

MATLAB (matrix laboratory) is a multi-paradigm numerical


computing environment and programming language developed by
MathWorks. MATLAB allows matrix manipulations, plotting of
functions and data, implementation of algorithms, creation of user
interfaces, and interfacing with programs written in other
languages, including C, C++, C#, Java, Fortran and Python.
Matlab has 3 environments:
1) Command window.
2) Editor window.
3) Simulink.
Working With Martices in MATLAB:

Matrix:
A rectangular arrangement of numbers/elements in M rows and N columns.

Declaration:

a = [10] is a matrix of 1 row and 1 column.

>> a = [10]

a=

10

>> size(a)

ans =

1 1

ROW MATRIX:

>> b = [1 , 2 , 3 , 4 , 5 , 6]

b=

1 2 3 4 5 6

>> size(b)

ans =

1 6

COLUMN MATRIX:
>> c = [1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7]

c=
1
2
3
4
5
6
7

>> size(c)

ans =

7 1

SQUARE MATRIX:

>> d = [ 1 , 2 , 3 ; 4, 5, 6 ; 7 , 8 , 9 ]

d=

1 2 3
4 5 6
7 8 9

>> size(d)

ans =

3 3

IDENTITY MATRIX:

>> n = eye(3,4)

n=

1 0 0 0
0 1 0 0
0 0 1 0
>> size(n)

ans =

3 4

UPPER TRIANGULAR MATRIX:

>> x = triu(d)

x=

1 2 3
0 5 6
0 0 9

LOWER TRIANGULAR MATRIX:

>> y = tril(d)

y=

1 0 0
4 5 0
7 8 9

DIFFERENT OPERATIONS ON MARTIX :

>> A = [ 1 , 2 , 3 ; 4 , 5 , 6 ; 5 , 5 , 4]

A=

1 2 3
4 5 6
5 5 4

>> B = [5 , 7 , 9 ; 11 , 12 , 13 ; 15 , 16 , 17 ]

B=

5 7 9
11 12 13
15 16 17
>> C= A+B

C=

6 9 12
15 17 19
20 21 21

>> C = A-B

C=

-4 -5 -6
-7 -7 -7
-10 -11 -13

>> C = A*B

C=

72 79 86
165 184 203
140 159 178

INVERSE OF MATRIX:

>> A = [ 1 , 2 , 3 ; 4 , 5 , 6 ; 5 , 5 , 4]

A=

1 2 3
4 5 6
5 5 4

>> v=inv(A)

v=

-3.3333 2.3333 -1.0000


4.6667 -3.6667 2.0000
-1.6667 1.6667 -1.0000
DETERMINANT OF A MATRIX:

>> A = [ 1 , 2 , 3 ; 4 , 5 , 6 ; 5 , 5 , 4]

A=

1 2 3
4 5 6
5 5 4

>> det(A)

ans =

3.0000

>> B = [5 , 7 , 9 ; 11 , 12 , 13 ; 15 , 16 , 17 ]

B=

5 7 9
11 12 13
15 16 17

>> det(B)

ans =

SCALAR MULTIPLICATION:

>> A = [ 1 , 2 , 3 ; 4 , 5 , 6 ; 5 , 5 , 4]

A=

1 2 3
4 5 6
5 5 4
>> C = 2*A

C=

2 4 6
8 10 12
10 10 8

You might also like