You are on page 1of 4

EXPERIMENT- 3 (A)

MATRIX CREATION

AIM: Write commands to create matrix.

SOFTWARE REQUIRED: PC loaded with SCILAB software.

THEORY: Vectors are special forms of matrices and contain only one row or one column.
Whereas scalars are special forms of matrices and contain only one row and one column. A
matrix with one row is called row vector and a matrix with single column is called column
vector.

PROCEDURE: Entering a matrix A matrix is an array of numbers. To type a matrix into


SCILAB we must: begin with a square bracket, [separate elements in a row with spaces or
commas (,) use a semicolon (;) to separate rows end the matrix with another square bracket ].

PROGRAM CODE (Matrix Creation):

 C=input('How many columns are there in P? ');


 R=input('How many rows are there in P? ');
 P=zeros(R:C);
 co=1;
 ro=1;
 while co<=C && ro<=R;
 if co==1
 P(co)=input('What is the first value of this column of P? ');
 co=co+1;
 elseif co>1;
 P(co)=input('What is the next value of this column of P? ');
 co=co+1;
 end
 ro=ro+1;
 end P=P(R:C)
 Disp()

OUTPUT:

How many columns are there in P? 2

Howmany rows are there in P? 2


What is the first value of this row of P? .2

P=

0.2000 0

00

What is the next value of this row of P? .2

P=

0.2000 0

0.2000 0

P=

0.2000

RESULT: Program for A matrix creation in Scilab has been executed successfully.
EXPERIMENT- 3 (B)
BASIC OPERATION ON MATRICES
AIM: Write commands to create matrix, manipulate them by addition, subtraction and
multiplication.

SOFTWARE REQUIRED: PC loaded with SCILAB software

THEORY: Vectors are special forms of matrices and contain only one row or one column.
Whereas scalars are special forms of matrices and contain only one row and one column. A
matrix with one row is called row vector and a matrix with single column is called column
vector.

PROCEDURE:
 Click on SCILAB Icon
 Click on launch scinotes.
 Type the program on editor window
 Save the program with filename.sce extension
 Execute the program and observe the output

PROGRAM:

 A = input('Enter the Matrix A……::');


 B = input('Enter the Matrix B……::');
// Find the size of matrices
 disp('The size of Matrix A is……:: ');
 disp(size(A));
 disp('The size of Matrix B is……:: ');
 disp(size(B));
// Addition of two matrices
 disp('Addition of A and B Matrices is…...:: ');
 disp(A + B);
// Subtration of two matrices
 disp('Subtraction of A and B Matrices is……:: ');
 disp(A - B);
//Multiplication (ELEMENT BY ELEMENT) of two matrices
 disp('Multiplication of A and B Matrices is......:: ');
 disp(A .* B);

OUTPUT:

Enter the Matrix A ::[1 2 ; 2 3;]

Enter the Matrix B ::[1 2 ; 2 3 ; ]

The size of Matrix A is……:: 2. 2.

The size of Matrix B is……:: 2. 2.

Addition of A and B Matrices is……:: 2. 4. 4. 6.

Subtraction of A and B Matrices is…….:: 0. 0. 0. 0.

Multiplication of A and B Matrices is……:: 1. 4. 4. 9.

Rank of Matrix A is……:: 2.

Determinant of Matrix A is……:: - 1.

Trace of Matrix A is……:: 4.

Inverse of Matrix A is……:: - 3. 2. 2. - 1.

RESULT: Hence basic operations on matrices are performed in Scilab.

You might also like