Maths Lab Sheet
Maths Lab Sheet
Maths Lab Sheet
INTRODUCTION
MATLAB is a programming platform designed especially for engineers and scientists to analyse
and design systems and products that transform our world. The heart of MATLAB is the MATLAB
language, a matrix-based language allowing the most natural expression of computational
mathematics.
APPLICATION OF MATLAB:
1
ADVANTAGE OF MATLAB:
1. Easy to use.
2. Documentation for every command.
3. Develop application with graphic user interface.
4. You can also plot 2D and 3D plots and animations too in MATLAB.
5. You can also write your own function and save it, so that it can be used later as a built-in
function.
DISADVANTAGE OF MATLAB:
1. The speed of MATLAB is slow, you can overcome this by properly structuring the
MATLAB program.
2. It is not open-source structure.
COMMANDS IN MATLAB:
Command Description
clc Clears the command window.
rand Generates random numbers from a uniform distribution.
eye Generates an identity matrix.
zeros Generates a matrix of zeros.
ones Generates a matrix of ones.
diag Extracts the diagonal elements of a matrix or creates a diagonal matrix.
size Returns the dimensions of a matrix.
sum Returns the sum of the elements in a matrix.
prod Returns the product of the elements in a matrix.
sort Sorts the elements in a matrix.
transpose or ' Transposes a matrix.
inv Computes the inverse of a matrix.
OBJECTIVE 1:
2
Construct 2 × 3 matrix on ones and 3 × 3 matrix on zeros.
WORKING EXPRESSION: Matrices can be created using square brackets to separate rows and
semicolons to separate columns. Matrix elements can be accessed using row and column indices,
and various arithmetic operations can be performed on matrices such as addition, subtraction,
multiplication, and division. MATLAB also provides a variety of built-in functions for working
with matrices, such as finding the transpose, inverse, eigenvalues, and eigenvectors.
0 0 0
1 1 1
Conclusion: Hence, 2×3 ones matrix is and 3×3 zeros matrix is 0 0 0.
1 1 1
0 0 0
OBJECTIVE 2:
3
Construct an identity matrix.
1 0 0
Conclusion: Hence the 3×3 identity matrix is 0 1 0.
0 0 1
OBJECTIVE 3:
1 2 3
Find the Transpose of the matrix A=
4 5 6
1 4
Conclusion: Hence, the transpose of the matrix is 2 5
3 6
4
OBJECTIVE 4:
1 4
Find the inverse of the matrix B=
7 3
−0.1200 0.1600
Conclusion: Hence, the inverse of the matrix is.
0.2800 −0.0400
OBJECTIVE 5:
Conclusion: Hence, the inverse of the matrices was verified as equal to identity matrix and its rank
is 3.
5
OBJECTIVE 6:
5 4 4 0
Find the sum and differences of two matrices, A= and B=
9 8 3 5
9 4 1 4
Conclusion: Hence, the sum is and difference is .
12 13 6 3
OBJECTIVE 7:
5 3 1 9
Find the product of two matrices A= 6 4 and B= 6 7
3 1 2 5
6
5 27
Conclusion: Hence, the product of two matrices is 36 28
6 5
OBJECTIVE 8:
OBJECTIVE 9:
7
Calculation and Output:
Conclusion: Therefore, x= 1, 3, 5.
OBJECTIVE 10:
WORKING EXPRESSION: In MATLAB, the dot product or inner dot product is like a matrix
multiplication. That is, we multiply a row vector by a column vector. The number of elements must
be same in both vectors. We can do this product by using the dot function in MATLAB.
OBJECTIVE 11:
WORKING EXPRESSION: The cross product or outer product a × b of two vectors is defined
only when both a and b are vectors in three dimensional space. MATLAB has a built-in function
‘cross’ for cross product.
8
Calculation and Output:
OBJECTIVE 12:
WORKING EXPRESSION: The scalar triple product is defined as the scalar obtained by taking
the dot product of the vector obtained from the cross product of two given vectors with a third
vector. Mathematically, it can be written as:
(a x b).c
The vector triple product is defined as the vector obtained from taking the cross product of two
given vectors and then taking the dot product of the result with a third vector. Mathematically, it can
be written as:
a x (b x c)
9
Conclusion: Therefore, we found that [a⃗ b⃗ c⃗ ]= -10 and a⃗ ×(b⃗ × c⃗ )=(-1, -11, 14).
OBJECTIVE 13:
If a⃗ = i⃗ + 4 ⃗j 7k⃗ , b⃗ = 2i⃗ - ⃗j + 4k⃗ , and c⃗ = -9 ⃗j + 18k⃗ . Find the dot and cross triple product of a
and b.
WORKING EXPRESSION: The cross product or outer product a × b of two vectors is defined
only when both a and b are vectors in three-dimensional space. MATLAB has a built-in function
‘cross’ for cross product.
10
Conclusion: Hence the scalar triple product is [0 -9 18] and vector triple product is [-324 -108 -
108].
11