22MAT11
22MAT11
MATLAB MANUAL
First Semester
2022-2023
MATLAB MANUAL
First Semester
2022-2023
Department of Mathematics
Faculty
Dr. Jyothi S
Dr. Vasanth Kumar S
Mrs. Rashmi Praveen
Mrs. Anusha
Ms. Shamitha Shetty
Ms. Swathy Shetty
Dr. Girija K P
Dr. Nagarjun Prabhu
Mr. Venkatramana P B
Dr. Chaitanya S Nayak
Mangalore Institute of Technology & Engineering, Moodabidri
List of Laboratory Experiments
7
Mangalore Institute of Technology & Engineering, Moodabidri
Introduction to MATLAB
8
Mangalore Institute of Technology & Engineering, Moodabidri
Introduction to MATLAB
9
Mangalore Institute of Technology & Engineering, Moodabidri
Introduction to MATLAB
10
Mangalore Institute of Technology & Engineering, Moodabidri
How to access
MATLAB R2022b
11
Mangalore Institute of Technology & Engineering, Moodabidri
How to access
MATLAB R2022b
12
Mangalore Institute of Technology & Engineering, Moodabidri
How to open and save files?
18
Mangalore Institute of Technology & Engineering, Moodabidri
Introduction to math toolbox
1. Symbolic Numbers
2. Symbolic Variables
4. Symbolic Arrays
19
Mangalore Institute of Technology & Engineering, Moodabidri
Symbolic Numbers
• To store a number as symbolic number in
workspace, we define the syntax sym(x).
• In following example, we see in first ‘x’ is stored
with default 4 decimal places and then as fraction
with sym(x) syntax.
20
Mangalore Institute of Technology & Engineering, Moodabidri
Symbolic Variables
• In workspace to store x, a, b and c as symbol and value as x, a, b and c,
we use the syntax ‘’syms’’
• In general, if not defined MATLAB will assume given variable as a
matrix.
• We define “ syms x a b c ”
Then in workspace x, a, b and c is stored as symbol and value as x, a, b
and c.
21
Mangalore Institute of Technology & Engineering, Moodabidri
Symbolic Equations
• To store a general Quadratic equations, we write
• syms x a b c
• f =a*x^2+ b*x + c
• If the required polynomial is f=5x^2-2x +7, then to
substitute old values a, b and c as 5, -2 and 7 we
use “subs” syntax. i.e.,
23
Mangalore Institute of Technology & Engineering, Moodabidri
Symbolic Functions
24
Mangalore Institute of Technology & Engineering, Moodabidri
Symbolic Arrays
• To symbolize any array we use “ syms ” syntax.
• For example, to write a Circulant Matrix of order 3 by 3 with a, b
and c as symbols, we use the following:
25
Mangalore Institute of Technology & Engineering, Moodabidri
Practice Problems
Construct
• A row matrix
• A column matrix
• A square matrix
• A rectangular matrix
• Addition of matrices
• Subtraction of matrices
• Multiplication of matrices
26
Mangalore Institute of Technology & Engineering, Moodabidri
Array Indexing
27
Mangalore Institute of Technology & Engineering, Moodabidri
Array Indexing
28
Mangalore Institute of Technology & Engineering, Moodabidri
Array Indexing
29
Mangalore Institute of Technology & Engineering, Moodabidri
Array Indexing
To find the diagonal elements
30
Mangalore Institute of Technology & Engineering, Moodabidri
Array Indexing
31
Mangalore Institute of Technology & Engineering, Moodabidri
Array Indexing
32
Mangalore Institute of Technology & Engineering, Moodabidri
Array Concatenation
Techniques
33
Mangalore Institute of Technology & Engineering, Moodabidri
Array Concatenation
Techniques
34
Mangalore Institute of Technology & Engineering, Moodabidri
2D plots for Cartesian
and polar curves
• Objectives
Use MATLAB
1. To plot 2D Cartesian curves.
2. To plot 2D polar curves.
3. To plot implicit functions.
35
Mangalore Institute of Technology & Engineering, Moodabidri
2D plots for Cartesian
and polar curves
• Syntex for the commands used
2dplot-fplot()
2dplot of symbolic expressions-fplot()
36
Mangalore Institute of Technology & Engineering, Moodabidri
2D plots for Cartesian
and polar curves
How to plot Straight line
38
2D plots for Cartesian
and polar curves
Exponential function
39
2D plots for Cartesian
and polar curves
Logarithmic function
40
2D plots for Cartesian
and polar curves
Trigonometric function
41
2D plots for Cartesian
and polar curves
Trigonometric function
42
2D plots for Cartesian
and polar curves
Trigonometric function
43
2D plots for Cartesian
and polar curves
Explicit function plot
Create a 2-D line plot by using fplot
44
2D plots for Cartesian
and polar curves
45
2D plots for Cartesian
and polar curves
Implicit function plot
Create a 2-D line plot by
using fplot
46
2D plots for Cartesian
and polar curves
Implicit function plot
47
2D plots for Cartesian
and polar curves
Plot Parametric curve
Plot 2-D parmetetric curve by
using fplot
48
2D plots for Cartesian
and polar curves
49
2D plots for Cartesian
and polar curves
3-D Plot
50
2D plots for Cartesian
and polar curves
Create Surface Plot
Create a 3-D surface by using
fsurf
Plot the paraboloid z = x^2 + y^2
51
2D plots for Cartesian
and polar curves
52
2D plots for Cartesian
and polar curves
53
2D plots for Cartesian
and polar curves
54
Mangalore Institute of Technology & Engineering, Moodabidri
Differentiation
55
Differentiation
56
Mangalore Institute of Technology & Engineering, Moodabidri
Differentiation
57
Mangalore Institute of Technology & Engineering, Moodabidri
Differentiation
58
Mangalore Institute of Technology & Engineering, Moodabidri
Differentiation
59
Mangalore Institute of Technology & Engineering, Moodabidri
Differentiation
60
Mangalore Institute of Technology & Engineering, Moodabidri
How to find the angle
between two curves
61
Mangalore Institute of Technology & Engineering, Moodabidri
How to find the angle
between two curves
62
Mangalore Institute of Technology & Engineering, Moodabidri
How to find the angle
between two curves
63
Mangalore Institute of Technology & Engineering, Moodabidri
How to find the angle
between two curves
64
Mangalore Institute of Technology & Engineering, Moodabidri
Working with Arrays
and Matrices
1. Array Creation
2. Indexing Arrays
3. Array Creation Functions
4. Array Concatenation Techniques
65
Mangalore Institute of Technology & Engineering, Moodabidri
Array Creation
Create a row/column/m*n array of four elements: -6, 0, 6, 9
66
Mangalore Institute of Technology & Engineering, Moodabidri
Array Creation
67
Mangalore Institute of Technology & Engineering, Moodabidri
Array Creation
68
Mangalore Institute of Technology & Engineering, Moodabidri
Thank you