0% found this document useful (0 votes)
16 views29 pages

Anish MATLAB New

Uploaded by

bhandarip498
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views29 pages

Anish MATLAB New

Uploaded by

bhandarip498
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Tribhuvan University Faculty of Humanities and Social Sciences

Model Multiple Campus


Janakpurdham-4, Dhanusha
(Tribhuvan University Affiliated)

MATLAB Report
Submitted By: Submitted To:
Name: Anish Karn Name: Mr. Rambahadur Sha
Roll No.: 27 Subject: Mathematics I
Programme: BCA (1st Semester) Subject Code: CAMT 104

Signature: _______________
2|Page

S.N. Particulars (Title) Page No. Date


Introduction to MATLAB
1. 3 2081/11/10
Matrix Introduction
2. 3 2081/11/11
Lab-1 (Matrix Arithmetic)
3. 4 2081/11/12
Lab-2 (Determinants of matrices)
4. 6 2081/11/14
Lab-3(Inverse of matrix)
5. 7 2081/11/16
Lab-4(Adjoint of matrix)
6. 9 2081/11/18
LAB:5(Rank of Matrices)
7. 10 2081/11/20
Lab-6(Solve by matrix method)
8. 11 2081/11/22
Lab-7 (Equation operations)
9. 12 2081/11/23
Lab-8(Vector)
10. 15 2081/11/26
Lab-9 (Sequence and series)
11. 17 2081/11/27
Lab-10(Plotting in graphs)
12. 19 2081/11/28
13 LAB-11(Analytical Geometry) 25 2081/12/03

14. Lab12(Permutation and Combination) 26 2081/12/04


3|Page

Signature: _____________

[Link] to MAtLAB
MATLAB (Matrix Laboratory) is a proprietary multi-paradigm programming
language and numerical computing environment, originally developed by
mathematician and computer programmer Cleve Moler in the 1970s. It is now
maintained and enhanced by MathWorks.
MATLAB excels at matrix manipulations, data visualization, algorithm
development, user interface creation, and interfacing with other programming
languages. It is one of the most powerful and widely-used tools in scientific and
engineering domains, occupying approximately 18 GB of memory, and is compatible
with both Windows and macOS platforms.
This software plays a crucial role in areas such as:
• Signal Processing
• Image Processing
• Machine Learning & Deep Learning
• Structural Analysis
• Electric Vehicle Design
MATLAB is widely used by Electrical, Mechanical, Civil, and Computer Engineers,
as well as researchers in various disciplines. As such, we will be using this
sophisticated application for our upcoming laboratory assignments to explore and
solve complex engineering problems.

[Link] IntroductIon
The concept of a matrix was introduced by Arthur Cayley in 1860. A matrix is a
two-dimensional array of numbers—which can be real or complex—arranged in
horizontal rows and vertical columns, and enclosed within round ( ) or square [ ]
brackets.
Each matrix is typically represented using a capital letter (like A, B, or M) for easy
identification.
Matrices are described by their dimensions in the format:
(number of rows) × (number of columns).
For example:
A 4 × 4 matrix (pronounced "four by four") has 4 rows and 4 columns.
4|Page

Example:-

Row Matrix: Matrix having only one row and single column is called row matrix

Example:-

Column Matrix: Matrix having one column and single rows is called column matrix
Example:-

Applications: Primarily used in field of sociology, economics, engineering, physical


sciences, statistics computer graphics and so on.

LAB-1 (MAtrIx ArIthMetIc)

A. Addition of Matrices: Two matrices only with same order can be added

together. example:
B. Subtraction of Matrices: Two matrices only with same order can be

subtracted together. example:

Q.1. If
5|Page

Find in MATLAB:
i) A+B ii) A-B

Solution: codes in MATLAB

C. Matrix Multiplication: Matrix multiplication is only possible if column of first


matrix and row of second matrix are equal and performed as row of first matrix
times column of second matrix.

Example: *
6|Page

Q.2. If using MATLAB find A*B?

Solution: codes in MATLAB:

LAB-2 (deterMInAnts of MAtrIces)

The determinant is a scalar value that is a function of the entries of a square matrix.
It allows characterizing some properties of the matrix and the linear map
represented by the matrix.

For 2x2 matrix

For 3x3 matrix


7|Page

Example:

Q.1. if A= find the determinant using MATLAB

Solution: codes in MATLAB

LAB-3(Inverse of MAtrIx)
Inverse of a Matrix:

The inverse of a matrix is a special matrix that, when multiplied by the original
matrix, results in the identity matrix.

Mathematically, for a matrix A, its inverse is denoted as A⁻¹, and:

A⋅A−1=A−1⋅A=I

Where I is the identity matrix.

Conditions to Find the Inverse:


8|Page

To find the inverse of a matrix, the following conditions must be met:

1. The matrix must be square (same number of rows and columns).

2. The matrix must be non-singular, meaning:

det(A)NOT=0

3. The adjoint (or adjugate) of the matrix is required.

Formula to Find the Inverse:

For a square matrix A, the inverse is calculated as:

A−1= adj(A)/det(A)

Where:

• adj(A) = adjoint of matrix A

• det(A) = determinant of matrix A

Q.2. find inverse of matrix


Solution: in MATLAB
9|Page

LAB-4(AdjoInt of MAtrIx)

Adjoint of Matrix: The matrix obtained by interchanging the columns and


rows of co-factor of matrix is called adjoint of matrix.

Example let A= and let Aij be the co-factor of a then ij

matrix of co- and adjoint will be


factor will be

transpose of the matrix of co-factor that is


10 | P a g e

Q.3. If find adjoint of A using MATLAB


Solution: in MATLAB
11 | P a g e

LAB:5(rAnk of MAtrIces)
The rank of a matrix is the maximum number of its linearly independent column
vectors (or row vectors). It is blatant that the rank of a matrix cannot exceed the
number of its rows or columns.

Example:

Therefore determinant is not equal to zero so as a result this given matrix has
rank of it’s order that is 3

Q.4. If find the rank of the matrix using MATLAB.

Solution: In MATLAB

LAB-6(soLve By MAtrIx Method)


Q.1. Find the value of x and y using MATLAB: x+3y=12 , 4x+2y=13 .
Solution: in MATLAB
12 | P a g e

Q.2. Find value of x,y,z from given equation using MATLAB: x+y+z=9,
2x+5y+7z=52 & 2x+y-z=0.
Solution:

LAB-7 (equAtIon operAtIons)


An equation is a formula that expresses the equality of two expressions, by
connecting them with the equals sign "="

Types of equation:
13 | P a g e

1. Linear Equation
2. Quadratic Equation
3. Polynomial Equation
4. Radical Equation

1. Linear Equation: Linear Equations are algebraic equations in which the highest
power (or degree) of the variable(s) is 1. These are called linear because their
graph represents a straight line.

Linear equations can be categorized based on the number of variables they contain:

• Linear equation in one variable (e.g., 2x - 5 = 0)

• Linear equation in two variables (e.g., 3x + 4y - 7 = 0)

• Linear equation in three variables (e.g., x + 2y - z = 6)

The standard form of a linear equation in two variables X and Y is: aX+bY−c=0

Where:

• a and b are the coefficients of variables XXX and YYY

• c is a constant

2. Quadratic Equation:
Quadratic Equations are equations where the highest power (degree) of the
variable is 2. These equations form a parabola when graphed. The standard
form of a quadratic equation in one variable x is:

ax2+bx+c=0 , where a≠0 a,

b, and c are real numbers

• a is the coefficient of x2, and it must not be zero

Methods to Solve a Quadratic Equation:

1. Splitting the Middle Term


Used when the equation can be factored easily.
14 | P a g e

2. Completing the Square


A method where the quadratic is rewritten as a perfect square trinomial.

3. Discriminant Method (Quadratic Formula)


Uses the formula:

o The expression b2−4ac is called the discriminant.

o It tells you the nature of the roots:

▪ If >0: two distinct real roots

▪ If =0: one real root (repeated)

▪ If <0: two complex roots

3. Polynomial Equations:
Equations with degree 3 are known as cubic equations. Here, 3 is the highest
exponent of at least one of the terms. The standard form of a cubic equation with
variable x is ax3 + bx2 + cx + d = 0, where a ≠ 0.

4. Radical Equations:
In a radical equation, a variable is lying inside a square root symbol or you can say
that the maximum exponent on a variable is ½

Example :

Q.1. solve 4x2+14x+10=0 manually and by using MATLAB?

Solution:

=>4x2+14x+10=0

=>4x2+10x+4x+10=0

=>2x(2x+5)+2(2x+5)=0

=>(2x+2)(2x+5)=0

Either 2x+2=0=>x=-1
15 | P a g e

Or 2x+5=0=>x=-5/2

In MATLAB

Q.2. solve x2+5x+6=0 manually and by using MATLAB.

Solution:
=>x2+5x+6=0

=>x2+2x+3x+6=0

=>x(x+2)+3(x+2)=0

=>(x+3)(x+2)=0

Either x+3=0=>x=-3

Or x+2=0=>x=-2

In MATLAB
16 | P a g e

LAB-8(vector)
Vector: Vector is an object that has both a magnitude and a direction. Geometrically,
we can picture a vector as a directed line segment, whose length is the magnitude of
the vector and with an arrow indicating the direction. The direction of the vector is
from its tail to its head.

Some types of vector:

1. Unit vectors: Vectors that have magnitude equals to 1 are called unit vectors,
denoted by a^. It is also called the multiplicative identity of vectors. The length
of unit vectors is 1. It is generally used to denote the direction of a vector.

2. Parallel vectors: Two or more vectors are said to be parallel vectors if they
have the same direction but not necessarily the same magnitude. Vectors are
said to be parallel if their cross product is 0(a×b=0).

3. Orthogonal vectors: Two or more vectors in space are said to be orthogonal if


the angle between them is 90 degrees. Vectors are said to be Orthogonal
vectors if their dot product is 0(a.b=0)
17 | P a g e

4. Zero or null vectors: The vector having magnitude 0 is called zero vector. Ex:

Magnitude/Length/modulus of vector: Magnitude of vector is aggregate root of


sum of individual square of each direction denoted by| |.

Dot product: dot product is sum of product of direction of each axis. This returns
magnitude and also termed as 'scalar product' mathematically: a1b1+a2b2+a3b3

Cross product: In mathematics, the cross product or vector product is a binary


operation on two vectors in a three-dimensional oriented Euclidean vector space,
and is denoted by the symbol times. This returns magnitude and direction of vector
and also termed as vector product.

Mathematically :
Q.1. find Magnitude of 4i+2j-k

Solution: in MATLAB

LAB-9 (sequence And serIes)


Sequence: A sequence is an ordered list of numbers that follows a specific pattern or
rule. Each number in the sequence is called a term. Sequences can be finite (with a
specific number of terms) or infinite (with an unlimited number of terms).

A sequence is usually represented as:


18 | P a g e

a1,a2,a3,…,an

Where:

• a1,a2,a3,… are the terms of the sequence.

• The pattern or rule defines how each term is generated based on the previous
terms.

Example:

The sequence of even numbers:

2,4,6,8,10,…

Here, the rule is that each term is the previous term plus 2.

Definition of Series: A series is the sum of the terms of a sequence. When you add the
terms of a sequence together, you form a series. The partial sum is the sum of the first
n terms of a sequence, and the infinite series refers to the sum of all terms of an infinite
sequence.

A series is represented as:

Sn=a1+a2+a3+ +an

Where:

• Sn is the sum of the first n terms of the sequence.

• The series could be finite (when n is finite) or infinite (when the sequence
continues forever).

Example:

For the sequence 2,4,6,8,10,… the corresponding series would be:

S=2+4+6+8+10+…

This is an infinite series because the sequence goes on indefinitely.


19 | P a g e

Key Differences:

• Sequence: An ordered list of numbers (no sum involved).

• Series: The sum of the terms of a sequence.

Q.1. Create a script file to find the sixth term and sum of the first six terms of the
arithmetic sequence: 3, 7, 11, 15, ... where a = 3 and d = 4
[The sixth term is: L = a + (n - 1) * d = 3 + (6 - 1) * 4 = 23
The sum of the first six terms: S = n / 2 * (a + L) = 6/2 * (3 + 23) = 78 , or
S = 6/2 * [2a + (n - 1) * d] = 6/2 * [2(3) + (6 - 1) * 4] =78.]
Solution:

LAB-10(pLottIng In grAphs)
Types of graphs:

1. Linear graphs: These types of graphs have no power raised and has equation
of y=mx+c where positivity or negativity of m decides the upward and
downward sloping of line.
20 | P a g e

2. Power graphs: These type of graphs are produced by raising power ex: y=ax2.
When power is even the graph line goes same direction as edge if power is
odd edges goes down and up.

3. Quadratic graphs: This type of graphs use quadratic equations (ax2+bx+c=0)


and returns parabola. Here a,b,c determines location of graphs and where a is
positive parabola is U-shaped and when a is negative parabola is umbrella
shaped.

4. Polynomial graphs: This type of graphs use polynomial equation(anxn+an-


1x +…+a2x +a1x +a0=0). Higher power the polynomial has more curves are
n1 2 1

encountered

5. Rational graphs: This type of graphs use rational function which don't give
irrational numbers and imaginary numbers example x+1 and 1/x.

6. Exponential graphs: These type of graphs are graphs where power is raised to
any constant ex: 2x these functions increases relatively faster after crossing the
axis.

7. Logarithmic graphs: These type of graphs are inverse of exponential graphs


uses equation y=logbx. Domain of logbx is always positive and real numbers
and if no base indicated base 10 is used.

8. Sine graph: these graphs use trigonometric function sin y=sin(x) and x is
measured in degree or radian.

Q.1. plot the following linear graph y=2x+10 within the range of [-8,10] Solution:
21 | P a g e

Q.2. plot the following quadratic graph y=4x2-14x+10=0 within the range of [-7,9]
Solution:
22 | P a g e

Q.3. plot the following polynomial graph y= x4+2x3-2x25x+6=0 within the range
of
[-4,24]
Solution:
23 | P a g e

Q.4. plot the following sine graph y=sin(x) which ranges from -4 to 4 with
increment of 0.1 Solution:
24 | P a g e

[Link] a parabola ranging from -4 to 4 where y=1/4x2 Solution:


25 | P a g e

LAB-11(AnALytIcAL geoMetry)

Analytical Geometry: Analytical Geometry, or Coordinate Geometry, is a branch of


mathematics that uses algebraic methods to represent and solve geometric problems. It
26 | P a g e

involves representing geometric shapes, such as points, lines, curves, and surfaces,
using a coordinate system (typically Cartesian coordinates). By assigning coordinates
to geometric objects, analytical geometry allows the use of algebraic equations and
formulas to analyze geometric relationships, solve problems involving distance, area,
volume, and other geometric properties, and find intersections between curves and
surfaces.
This method bridges geometry and algebra, allowing for the study of geometric objects
through algebraic equations.

Q.1. Create a script file to evaluate the dot product u.v if u = [[1, 0]] and v = [[2, 2]]
Solution:

LAB12(perMutAtIon And coMBInAtIon)


27 | P a g e
28 | P a g e

Q.1. Create a script file to evaluate factorial of a positive integer n. Solution:


29 | P a g e

Q. 2. How many permutations and combinations can be made of the 26 letters of the
alphabet, taking six at a time?
Solution:

You might also like