SlideShare a Scribd company logo
1 of 47
Download to read offline
By
ANIL MAURYA
ELECTRICAL & ELECTRONICS
ENGINEER
1
Topics
Introduction
MATLAB Environment
Getting Help
Variables
Vectors, Matrices, and Linear Algebra
Mathematical Functions and Applications
PlottingPlotting
Selection Programming
M-Files
User Defined Functions
Applications
Specific topics
2ANIL MAURYA Electrical & Electronics Engineer
Introduction
What is MATLAB ?
• MATLAB is a computer program that combines computation and
visualization power that makes it particularly useful tool for
engineers.
• MATLAB is an executive program, and a script can be made with a
list of MATLAB commands like other programming language.
3
MATLAB Stands forMATLAB Stands for MATMATrixrix LABLABoratoryoratory..
•• The system was designed to make matrix computation particularlyThe system was designed to make matrix computation particularly
easy.easy.
The MATLAB environment allows the user to:
• manage variables
• import and export data
• perform calculations
• generate plots
• develop and manage files for use with MATLAB.
ANIL MAURYA Electrical & Electronics Engineer
MATLAB
Environment
To start MATLAB:
STARTSTART
PROGRAMS
MATLAB 7.0
MATLAB 7.0
4ANIL MAURYA Electrical & Electronics Engineer
Display Windows
5ANIL MAURYA Electrical & Electronics Engineer
Display Windows (con’t…)
Graphic (Figure) Window
Displays plots and graphs
Created in response to graphics commands.
M-file editor/debugger windowM-file editor/debugger window
Create and edit scripts of commands called M-files.
6ANIL MAURYA Electrical & Electronics Engineer
Getting Help
Type one of following commands in the command
window:
help – lists all the help topic
help topic – provides help for the specified topic
help command – provides help for the specified commandhelp command – provides help for the specified command
help help – provides information on use of the help command
helpwin – opens a separate help window for navigation
lookfor keyword – Search all M-files for keyword
PWD prints working directory
7ANIL MAURYA Electrical & Electronics Engineer
Getting Help (con’t…)
Google “MATLAB helpdesk”
Go to the online HelpDesk provided by
www.mathworks.com
8
You can find EVERYTHING you
need to know about MATLAB
from the online HelpDesk.
ANIL MAURYA Electrical & Electronics Engineer
Variables
Variable names:
Must start with a letter
May contain only letters, digits, and the underscore “_”
Matlab is case sensitive, i.e. one & OnE are different variables.
Matlab only recognizes the first 31 characters in a variable name.
Assignment statement:Assignment statement:
Variable = number;
Variable = expression;
Example:
>> tutorial = 1234;
>> tutorial = 1234
tutorial =
1234
9
NOTE: when a semi-colon
”;” is placed at the end of
each command, the result
is not displayed.
ANIL MAURYA Electrical & Electronics Engineer
Variables (con’t…)
Special variables:
ans : default variable name for the result
pi: π = 3.1415926…………
eps: ∈ = 2.2204e-016, smallest amount by which 2 numbers can differ.
Inf or inf : ∞, infinity
NaN or nan: not-a-number
Commands involving variables:
who: lists the names of defined variables
whos: lists the names and sizes of defined variables
clear: clears all varialbes, reset the default values of special
variables.
clear name: clears the variable name
clc: clears the command window
clf: clears the current figure and the graph window.
10ANIL MAURYA Electrical & Electronics Engineer
11ANIL MAURYA Electrical & Electronics Engineer
Vectors, Matrices and Linear Algebra
Vectors
Array Operations
Matrices
Solutions to Systems of Linear Equations.
12ANIL MAURYA Electrical & Electronics Engineer
Vectors
A row vector in MATLAB can be created by an explicit list, starting with a left bracket,
entering the values separated by spaces (or commas) and closing the vector with a right
bracket.
A column vector can be created the same way, and the rows are separated by semicolons.
Example:
>> x = [ 0 0.25*pi 0.5*pi 0.75*pi pi ]
x =x =
0 0.7854 1.5708 2.3562 3.1416
>> y = [ 0; 0.25*pi; 0.5*pi; 0.75*pi; pi ]
y =
0
0.7854
1.5708
2.3562
3.1416
13
x is a row vector.
y is a column vector.
ANIL MAURYA Electrical & Electronics Engineer
Vectors (con’t…)
Some useful commands:
x = start:endx = start:end create row vector x starting with start, counting bycreate row vector x starting with start, counting by
one, ending at endone, ending at end
x = start:increment:endx = start:increment:end create row vector x starting with start, counting bycreate row vector x starting with start, counting by
increment, ending at or before endincrement, ending at or before end
create row vector x starting with start, ending atcreate row vector x starting with start, ending at
14
linspace(start,end,number)linspace(start,end,number) create row vector x starting with start, ending atcreate row vector x starting with start, ending at
end, having number elementsend, having number elements
length(x)length(x) returns the length of vector xreturns the length of vector x
y = x’y = x’ transpose of vector xtranspose of vector x
dot (x, y)dot (x, y) returns the scalar dot product of the vector x and y.returns the scalar dot product of the vector x and y.
ANIL MAURYA Electrical & Electronics Engineer
15ANIL MAURYA Electrical & Electronics Engineer
16ANIL MAURYA Electrical & Electronics Engineer
Vectors (con’t…)
Vector Addressing – A vector element is addressed in MATLAB with an integer
index enclosed in parentheses.
Example:
>> x(3)
ans =
1.5708 3rd element of vector x1.5708
17
1st to 3rd elements of vector x
The colon notation may be used to address a block of elements.The colon notation may be used to address a block of elements.
(start : increment : end)(start : increment : end)
start is the starting index, increment is the amount to add to each successive index, and endstart is the starting index, increment is the amount to add to each successive index, and end
is the ending index. A shortened format (start : end) may be used if increment is 1.is the ending index. A shortened format (start : end) may be used if increment is 1.
Example:Example:
>> x(1:3)>> x(1:3)
ans =ans =
0 0.7854 1.57080 0.7854 1.5708
NOTE: MATLAB index starts at 1.
3rd element of vector x
ANIL MAURYA Electrical & Electronics Engineer
Array Operations
Scalar-Array Mathematics
For addition, subtraction, multiplication, and division of an array
by a scalar simply apply the operations to all elements of the array.
Example:
>> f = [ 1 2; 3 4]
f =
1 21 2
3 4
>> g = 2*f – 1
g =
1 3
5 7
18
Each element in the array f is
multiplied by 2, then subtracted
by 1.
ANIL MAURYA Electrical & Electronics Engineer
Array Operations (con’t…)
Element-by-Element Array-Array Mathematics.
OperationOperation Algebraic FormAlgebraic Form MATLABMATLAB
AdditionAddition a + ba + b a + ba + b
SubtractionSubtraction aa –– bb aa –– bb
MultiplicationMultiplication a x ba x b a .* ba .* b
19
MultiplicationMultiplication a x ba x b a .* ba .* b
DivisionDivision aa ÷÷ bb a ./ ba ./ b
ExponentiationExponentiation aabb a .^ ba .^ b
Example:Example:
>> x = [ 1 2 3 ];>> x = [ 1 2 3 ];
>> y = [ 4 5 6 ];>> y = [ 4 5 6 ];
>> z = x .* y>> z = x .* y
z =z =
4 10 184 10 18
Each element in x is multiplied by
the corresponding element in y.
ANIL MAURYA Electrical & Electronics Engineer
Matrices
A Matrix array is two-dimensional, having both multiple rows and multiple columns,
similar to vector arrays:
it begins with [, and end with ]
spaces or commas are used to separate elements in a row
semicolon or enter is used to separate rows.
A is an m x n matrix.
20
•Example:
>> f = [ 1 2 3; 4 5 6]
f =
1 2 3
4 5 6
>> h = [ 2 4 6
1 3 5]
h =
2 4 6
1 3 5
the main diagonal
ANIL MAURYA Electrical & Electronics Engineer
Matrices (con’t…)
Matrix Addressing:
-- matrixname(row, column)
-- colon may be used in place of a row or column reference to
select the entire row or column.
recall:
Example:
21
recall:
f =
1 2 3
4 5 6
h =
2 4 6
1 3 5
Example:
>> f(2,3)
ans =
6
>> h(:,1)
ans =
2
1
ANIL MAURYA Electrical & Electronics Engineer
Matrices (con’t…)
Some useful commands:
zeros(n)
zeros(m,n)
ones(n)
returns a n x n matrix of zeros
returns a m x n matrix of zeros
returns a n x n matrix of ones
22
ones(n)
ones(m,n)
size (A)
length(A)
returns a n x n matrix of ones
returns a m x n matrix of ones
for a m x n matrix A, returns the row vector [m,n]
containing the number of rows and columns in
matrix.
returns the larger of the number of rows or
columns in A.
ANIL MAURYA Electrical & Electronics Engineer
Matrices (con’t…)
TransposeTranspose B = A’B = A’
Identity MatrixIdentity Matrix eye(n)eye(n) returns an n x n identity matrixreturns an n x n identity matrix
eye(m,n)eye(m,n) returns an m x n matrix with ones on the mainreturns an m x n matrix with ones on the main
diagonal and zeros elsewhere.diagonal and zeros elsewhere.
Addition and subtractionAddition and subtraction C = A + BC = A + B
more commands
23
Addition and subtractionAddition and subtraction C = A + BC = A + B
C = AC = A –– BB
Scalar MultiplicationScalar Multiplication B =B = ααA, whereA, where αα is a scalar.is a scalar.
Matrix MultiplicationMatrix Multiplication C = A*BC = A*B
Matrix InverseMatrix Inverse B = inv(A), A must be a square matrix in this case.B = inv(A), A must be a square matrix in this case.
rank (A)rank (A) returns the rank of the matrix A.returns the rank of the matrix A.
Matrix PowersMatrix Powers B = A.^2B = A.^2 squares each element in the matrixsquares each element in the matrix
C = A * AC = A * A computes A*A, and A must be a square matrix.computes A*A, and A must be a square matrix.
DeterminantDeterminant det (A), and A must be a square matrix.det (A), and A must be a square matrix.
A, B, C are matrices, and m, n, α are scalars.
ANIL MAURYA Electrical & Electronics Engineer
Solutions to Systems of Linear Equations
Example: a system of 3 linear equations with 3 unknowns (x1, x2, x3):
3x1 + 2x2 – x3 = 10
-x1 + 3x2 + 2x3 = 5
x1 – x2 – x3 = -1
 −123 x 10
Let :
24
Then, the system can be described as:
Ax = b










−−
−
−
=
111
231
123
A










=
3
2
1
x
x
x
x










−
=
1
5
10
b
ANIL MAURYA Electrical & Electronics Engineer
Solutions to Systems of Linear Equations (con’t…)
Solution by Matrix Inverse:
Ax = b
A-1Ax = A-1b
x = A-1b
MATLAB:
>> A = [ 3 2 -1; -1 3 2; 1 -1 -1];
Solution by Matrix Division:Solution by Matrix Division:
The solution to the equationThe solution to the equation
Ax = bAx = b
can be computed usingcan be computed using left divisionleft division..
MATLAB:
>> A = [ 3 2 -1; -1 3 2; 1 -1 -1];>> A = [ 3 2 -1; -1 3 2; 1 -1 -1];
>> b = [ 10; 5; -1];
>> x = inv(A)*b
x =
-2.0000
5.0000
-6.0000
25
Answer:
x1 = -2, x2 = 5, x3 = -6
Answer:
x1 = -2, x2 = 5, x3 = -6
NOTE:
left division: Ab b ÷ A right division: x/y x ÷ y
>> A = [ 3 2 -1; -1 3 2; 1 -1 -1];
>> b = [ 10; 5; -1];
>> x = Ab
x =
-2.0000
5.0000
-6.0000
ANIL MAURYA Electrical & Electronics Engineer
26ANIL MAURYA Electrical & Electronics Engineer
27ANIL MAURYA Electrical & Electronics Engineer
28ANIL MAURYA Electrical & Electronics Engineer
29ANIL MAURYA Electrical & Electronics Engineer
30ANIL MAURYA Electrical & Electronics Engineer
31ANIL MAURYA Electrical & Electronics Engineer
32ANIL MAURYA Electrical & Electronics Engineer
33ANIL MAURYA Electrical & Electronics Engineer
34ANIL MAURYA Electrical & Electronics Engineer
35ANIL MAURYA Electrical & Electronics Engineer
36ANIL MAURYA Electrical & Electronics Engineer
37ANIL MAURYA Electrical & Electronics Engineer
38ANIL MAURYA Electrical & Electronics Engineer
39ANIL MAURYA Electrical & Electronics Engineer
40ANIL MAURYA Electrical & Electronics Engineer
41ANIL MAURYA Electrical & Electronics Engineer
42ANIL MAURYA Electrical & Electronics Engineer
43ANIL MAURYA Electrical & Electronics Engineer
44ANIL MAURYA Electrical & Electronics Engineer
45ANIL MAURYA Electrical & Electronics Engineer
46ANIL MAURYA Electrical & Electronics Engineer
47ANIL MAURYA Electrical & Electronics Engineer

More Related Content

What's hot

MATLAB Basics-Part1
MATLAB Basics-Part1MATLAB Basics-Part1
MATLAB Basics-Part1Elaf A.Saeed
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabMohan Raj
 
Matlab Introduction
Matlab IntroductionMatlab Introduction
Matlab Introductionideas2ignite
 
Matlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processingMatlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processingDr. Manjunatha. P
 
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulinkMATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulinkreddyprasad reddyvari
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabTarun Gehlot
 
Matlab matrices and arrays
Matlab matrices and arraysMatlab matrices and arrays
Matlab matrices and arraysAmeen San
 
Matlab Tutorial for Beginners - I
Matlab Tutorial for Beginners - IMatlab Tutorial for Beginners - I
Matlab Tutorial for Beginners - IVijay Kumar Gupta
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introductionAmeen San
 
Matlab-Data types and operators
Matlab-Data types and operatorsMatlab-Data types and operators
Matlab-Data types and operatorsLuckshay Batra
 
Brief Introduction to Matlab
Brief  Introduction to MatlabBrief  Introduction to Matlab
Brief Introduction to MatlabTariq kanher
 
Matlab introduction lecture 1
Matlab introduction lecture 1Matlab introduction lecture 1
Matlab introduction lecture 1Mohamed Awni
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLABRavikiran A
 

What's hot (20)

MATLAB Basics-Part1
MATLAB Basics-Part1MATLAB Basics-Part1
MATLAB Basics-Part1
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Matlab Introduction
Matlab IntroductionMatlab Introduction
Matlab Introduction
 
Matlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processingMatlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processing
 
Matlab Basic Tutorial
Matlab Basic TutorialMatlab Basic Tutorial
Matlab Basic Tutorial
 
Matlab ppt
Matlab pptMatlab ppt
Matlab ppt
 
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulinkMATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
 
MATLAB Programming
MATLAB Programming MATLAB Programming
MATLAB Programming
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
Matlab matrices and arrays
Matlab matrices and arraysMatlab matrices and arrays
Matlab matrices and arrays
 
Matlab Tutorial for Beginners - I
Matlab Tutorial for Beginners - IMatlab Tutorial for Beginners - I
Matlab Tutorial for Beginners - I
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Matlab-Data types and operators
Matlab-Data types and operatorsMatlab-Data types and operators
Matlab-Data types and operators
 
Matlab Workshop Presentation
Matlab Workshop PresentationMatlab Workshop Presentation
Matlab Workshop Presentation
 
2D Plot Matlab
2D Plot Matlab2D Plot Matlab
2D Plot Matlab
 
Brief Introduction to Matlab
Brief  Introduction to MatlabBrief  Introduction to Matlab
Brief Introduction to Matlab
 
Matlab introduction lecture 1
Matlab introduction lecture 1Matlab introduction lecture 1
Matlab introduction lecture 1
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
Fundamentals of matlab
Fundamentals of matlabFundamentals of matlab
Fundamentals of matlab
 

Viewers also liked

Summer training matlab
Summer training matlab Summer training matlab
Summer training matlab Arshit Rai
 
Fair Meter: E360
Fair Meter: E360Fair Meter: E360
Fair Meter: E360Landis+Gyr
 
Transducer signal conditioners
Transducer signal conditionersTransducer signal conditioners
Transducer signal conditionerser sheela siva
 
electric vs fuel injector cars
electric vs fuel injector carselectric vs fuel injector cars
electric vs fuel injector carsAnil Kumar
 
Understandingandusingenglishgrammarwithanswerkeyandaudiocds4theditiona4 14082...
Understandingandusingenglishgrammarwithanswerkeyandaudiocds4theditiona4 14082...Understandingandusingenglishgrammarwithanswerkeyandaudiocds4theditiona4 14082...
Understandingandusingenglishgrammarwithanswerkeyandaudiocds4theditiona4 14082...Guto Carvalho
 
Basic English Grammar (3rd edition)
Basic English Grammar (3rd edition)Basic English Grammar (3rd edition)
Basic English Grammar (3rd edition)Melania Neata
 
SMART METER ppt
SMART METER pptSMART METER ppt
SMART METER pptAyush Jain
 
Matlab for Electrical Engineers
Matlab for Electrical EngineersMatlab for Electrical Engineers
Matlab for Electrical EngineersManish Joshi
 
Advanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & ScientistsAdvanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & ScientistsRay Phan
 
Latest Electrical Mini Projects For EEE Students
Latest Electrical Mini Projects For EEE StudentsLatest Electrical Mini Projects For EEE Students
Latest Electrical Mini Projects For EEE Studentselprocus
 
Introduction to digital image processing
Introduction to digital image processingIntroduction to digital image processing
Introduction to digital image processingHossain Md Shakhawat
 

Viewers also liked (16)

Summer training matlab
Summer training matlab Summer training matlab
Summer training matlab
 
Fair Meter: E360
Fair Meter: E360Fair Meter: E360
Fair Meter: E360
 
Smart grid
Smart gridSmart grid
Smart grid
 
Transducer signal conditioners
Transducer signal conditionersTransducer signal conditioners
Transducer signal conditioners
 
electric vs fuel injector cars
electric vs fuel injector carselectric vs fuel injector cars
electric vs fuel injector cars
 
Libro de MATLAB
Libro de MATLABLibro de MATLAB
Libro de MATLAB
 
Understandingandusingenglishgrammarwithanswerkeyandaudiocds4theditiona4 14082...
Understandingandusingenglishgrammarwithanswerkeyandaudiocds4theditiona4 14082...Understandingandusingenglishgrammarwithanswerkeyandaudiocds4theditiona4 14082...
Understandingandusingenglishgrammarwithanswerkeyandaudiocds4theditiona4 14082...
 
Basic English Grammar (3rd edition)
Basic English Grammar (3rd edition)Basic English Grammar (3rd edition)
Basic English Grammar (3rd edition)
 
Microwave imaging
Microwave imagingMicrowave imaging
Microwave imaging
 
SMART METER ppt
SMART METER pptSMART METER ppt
SMART METER ppt
 
Matlab for Electrical Engineers
Matlab for Electrical EngineersMatlab for Electrical Engineers
Matlab for Electrical Engineers
 
Advanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & ScientistsAdvanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & Scientists
 
Smart Meter Basics and Benefits
Smart Meter Basics and BenefitsSmart Meter Basics and Benefits
Smart Meter Basics and Benefits
 
ppt on Smart Grid
ppt on Smart Gridppt on Smart Grid
ppt on Smart Grid
 
Latest Electrical Mini Projects For EEE Students
Latest Electrical Mini Projects For EEE StudentsLatest Electrical Mini Projects For EEE Students
Latest Electrical Mini Projects For EEE Students
 
Introduction to digital image processing
Introduction to digital image processingIntroduction to digital image processing
Introduction to digital image processing
 

Similar to Basics of matlab

Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functionsjoellivz
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.pptnaveen_setty
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.pptaboma2hawi
 
Basic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptxBasic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptxPremanandS3
 
A complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsA complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsMukesh Kumar
 
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxandreecapon
 
Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4Randa Elanwar
 
Intro to MATLAB and K-mean algorithm
Intro to MATLAB and K-mean algorithmIntro to MATLAB and K-mean algorithm
Intro to MATLAB and K-mean algorithmkhalid Shah
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabBilawalBaloch1
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMohd Esa
 
Matlab ch1 (4)
Matlab ch1 (4)Matlab ch1 (4)
Matlab ch1 (4)mohsinggg
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabDnyanesh Patil
 

Similar to Basics of matlab (20)

Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functions
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
EPE821_Lecture3.pptx
EPE821_Lecture3.pptxEPE821_Lecture3.pptx
EPE821_Lecture3.pptx
 
Basic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptxBasic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptx
 
A complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsA complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projects
 
Basic concepts in_matlab
Basic concepts in_matlabBasic concepts in_matlab
Basic concepts in_matlab
 
Matlab booklet
Matlab bookletMatlab booklet
Matlab booklet
 
Matlab
MatlabMatlab
Matlab
 
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
 
Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4
 
Intro to MATLAB and K-mean algorithm
Intro to MATLAB and K-mean algorithmIntro to MATLAB and K-mean algorithm
Intro to MATLAB and K-mean algorithm
 
Matlab
MatlabMatlab
Matlab
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd Esa
 
Matlab ch1 (4)
Matlab ch1 (4)Matlab ch1 (4)
Matlab ch1 (4)
 
Matlab1
Matlab1Matlab1
Matlab1
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 

More from Anil Maurya

Training report-hzl-cszl
Training report-hzl-cszlTraining report-hzl-cszl
Training report-hzl-cszlAnil Maurya
 
Three phase shifter appliance
Three phase shifter applianceThree phase shifter appliance
Three phase shifter applianceAnil Maurya
 
Report on robotic control
Report on robotic controlReport on robotic control
Report on robotic controlAnil Maurya
 
Report on minor project
Report on minor projectReport on minor project
Report on minor projectAnil Maurya
 
Ppt on rs logix 5000
Ppt on rs logix 5000Ppt on rs logix 5000
Ppt on rs logix 5000Anil Maurya
 
Microprocessor 8051
Microprocessor 8051Microprocessor 8051
Microprocessor 8051Anil Maurya
 
Presentation on PLC and SCADA
Presentation on PLC and SCADAPresentation on PLC and SCADA
Presentation on PLC and SCADAAnil Maurya
 

More from Anil Maurya (13)

Zinc ppt
Zinc pptZinc ppt
Zinc ppt
 
Training report-hzl-cszl
Training report-hzl-cszlTraining report-hzl-cszl
Training report-hzl-cszl
 
Three phase shifter appliance
Three phase shifter applianceThree phase shifter appliance
Three phase shifter appliance
 
Simulations
SimulationsSimulations
Simulations
 
Simulation 2
Simulation 2Simulation 2
Simulation 2
 
Report on robotic control
Report on robotic controlReport on robotic control
Report on robotic control
 
Report on minor project
Report on minor projectReport on minor project
Report on minor project
 
Ppt on rs logix 5000
Ppt on rs logix 5000Ppt on rs logix 5000
Ppt on rs logix 5000
 
Plc report
Plc reportPlc report
Plc report
 
Ppt on robotic
Ppt on roboticPpt on robotic
Ppt on robotic
 
Plc report
Plc reportPlc report
Plc report
 
Microprocessor 8051
Microprocessor 8051Microprocessor 8051
Microprocessor 8051
 
Presentation on PLC and SCADA
Presentation on PLC and SCADAPresentation on PLC and SCADA
Presentation on PLC and SCADA
 

Recently uploaded

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Recently uploaded (20)

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

Basics of matlab

  • 1. By ANIL MAURYA ELECTRICAL & ELECTRONICS ENGINEER 1
  • 2. Topics Introduction MATLAB Environment Getting Help Variables Vectors, Matrices, and Linear Algebra Mathematical Functions and Applications PlottingPlotting Selection Programming M-Files User Defined Functions Applications Specific topics 2ANIL MAURYA Electrical & Electronics Engineer
  • 3. Introduction What is MATLAB ? • MATLAB is a computer program that combines computation and visualization power that makes it particularly useful tool for engineers. • MATLAB is an executive program, and a script can be made with a list of MATLAB commands like other programming language. 3 MATLAB Stands forMATLAB Stands for MATMATrixrix LABLABoratoryoratory.. •• The system was designed to make matrix computation particularlyThe system was designed to make matrix computation particularly easy.easy. The MATLAB environment allows the user to: • manage variables • import and export data • perform calculations • generate plots • develop and manage files for use with MATLAB. ANIL MAURYA Electrical & Electronics Engineer
  • 4. MATLAB Environment To start MATLAB: STARTSTART PROGRAMS MATLAB 7.0 MATLAB 7.0 4ANIL MAURYA Electrical & Electronics Engineer
  • 5. Display Windows 5ANIL MAURYA Electrical & Electronics Engineer
  • 6. Display Windows (con’t…) Graphic (Figure) Window Displays plots and graphs Created in response to graphics commands. M-file editor/debugger windowM-file editor/debugger window Create and edit scripts of commands called M-files. 6ANIL MAURYA Electrical & Electronics Engineer
  • 7. Getting Help Type one of following commands in the command window: help – lists all the help topic help topic – provides help for the specified topic help command – provides help for the specified commandhelp command – provides help for the specified command help help – provides information on use of the help command helpwin – opens a separate help window for navigation lookfor keyword – Search all M-files for keyword PWD prints working directory 7ANIL MAURYA Electrical & Electronics Engineer
  • 8. Getting Help (con’t…) Google “MATLAB helpdesk” Go to the online HelpDesk provided by www.mathworks.com 8 You can find EVERYTHING you need to know about MATLAB from the online HelpDesk. ANIL MAURYA Electrical & Electronics Engineer
  • 9. Variables Variable names: Must start with a letter May contain only letters, digits, and the underscore “_” Matlab is case sensitive, i.e. one & OnE are different variables. Matlab only recognizes the first 31 characters in a variable name. Assignment statement:Assignment statement: Variable = number; Variable = expression; Example: >> tutorial = 1234; >> tutorial = 1234 tutorial = 1234 9 NOTE: when a semi-colon ”;” is placed at the end of each command, the result is not displayed. ANIL MAURYA Electrical & Electronics Engineer
  • 10. Variables (con’t…) Special variables: ans : default variable name for the result pi: π = 3.1415926………… eps: ∈ = 2.2204e-016, smallest amount by which 2 numbers can differ. Inf or inf : ∞, infinity NaN or nan: not-a-number Commands involving variables: who: lists the names of defined variables whos: lists the names and sizes of defined variables clear: clears all varialbes, reset the default values of special variables. clear name: clears the variable name clc: clears the command window clf: clears the current figure and the graph window. 10ANIL MAURYA Electrical & Electronics Engineer
  • 11. 11ANIL MAURYA Electrical & Electronics Engineer
  • 12. Vectors, Matrices and Linear Algebra Vectors Array Operations Matrices Solutions to Systems of Linear Equations. 12ANIL MAURYA Electrical & Electronics Engineer
  • 13. Vectors A row vector in MATLAB can be created by an explicit list, starting with a left bracket, entering the values separated by spaces (or commas) and closing the vector with a right bracket. A column vector can be created the same way, and the rows are separated by semicolons. Example: >> x = [ 0 0.25*pi 0.5*pi 0.75*pi pi ] x =x = 0 0.7854 1.5708 2.3562 3.1416 >> y = [ 0; 0.25*pi; 0.5*pi; 0.75*pi; pi ] y = 0 0.7854 1.5708 2.3562 3.1416 13 x is a row vector. y is a column vector. ANIL MAURYA Electrical & Electronics Engineer
  • 14. Vectors (con’t…) Some useful commands: x = start:endx = start:end create row vector x starting with start, counting bycreate row vector x starting with start, counting by one, ending at endone, ending at end x = start:increment:endx = start:increment:end create row vector x starting with start, counting bycreate row vector x starting with start, counting by increment, ending at or before endincrement, ending at or before end create row vector x starting with start, ending atcreate row vector x starting with start, ending at 14 linspace(start,end,number)linspace(start,end,number) create row vector x starting with start, ending atcreate row vector x starting with start, ending at end, having number elementsend, having number elements length(x)length(x) returns the length of vector xreturns the length of vector x y = x’y = x’ transpose of vector xtranspose of vector x dot (x, y)dot (x, y) returns the scalar dot product of the vector x and y.returns the scalar dot product of the vector x and y. ANIL MAURYA Electrical & Electronics Engineer
  • 15. 15ANIL MAURYA Electrical & Electronics Engineer
  • 16. 16ANIL MAURYA Electrical & Electronics Engineer
  • 17. Vectors (con’t…) Vector Addressing – A vector element is addressed in MATLAB with an integer index enclosed in parentheses. Example: >> x(3) ans = 1.5708 3rd element of vector x1.5708 17 1st to 3rd elements of vector x The colon notation may be used to address a block of elements.The colon notation may be used to address a block of elements. (start : increment : end)(start : increment : end) start is the starting index, increment is the amount to add to each successive index, and endstart is the starting index, increment is the amount to add to each successive index, and end is the ending index. A shortened format (start : end) may be used if increment is 1.is the ending index. A shortened format (start : end) may be used if increment is 1. Example:Example: >> x(1:3)>> x(1:3) ans =ans = 0 0.7854 1.57080 0.7854 1.5708 NOTE: MATLAB index starts at 1. 3rd element of vector x ANIL MAURYA Electrical & Electronics Engineer
  • 18. Array Operations Scalar-Array Mathematics For addition, subtraction, multiplication, and division of an array by a scalar simply apply the operations to all elements of the array. Example: >> f = [ 1 2; 3 4] f = 1 21 2 3 4 >> g = 2*f – 1 g = 1 3 5 7 18 Each element in the array f is multiplied by 2, then subtracted by 1. ANIL MAURYA Electrical & Electronics Engineer
  • 19. Array Operations (con’t…) Element-by-Element Array-Array Mathematics. OperationOperation Algebraic FormAlgebraic Form MATLABMATLAB AdditionAddition a + ba + b a + ba + b SubtractionSubtraction aa –– bb aa –– bb MultiplicationMultiplication a x ba x b a .* ba .* b 19 MultiplicationMultiplication a x ba x b a .* ba .* b DivisionDivision aa ÷÷ bb a ./ ba ./ b ExponentiationExponentiation aabb a .^ ba .^ b Example:Example: >> x = [ 1 2 3 ];>> x = [ 1 2 3 ]; >> y = [ 4 5 6 ];>> y = [ 4 5 6 ]; >> z = x .* y>> z = x .* y z =z = 4 10 184 10 18 Each element in x is multiplied by the corresponding element in y. ANIL MAURYA Electrical & Electronics Engineer
  • 20. Matrices A Matrix array is two-dimensional, having both multiple rows and multiple columns, similar to vector arrays: it begins with [, and end with ] spaces or commas are used to separate elements in a row semicolon or enter is used to separate rows. A is an m x n matrix. 20 •Example: >> f = [ 1 2 3; 4 5 6] f = 1 2 3 4 5 6 >> h = [ 2 4 6 1 3 5] h = 2 4 6 1 3 5 the main diagonal ANIL MAURYA Electrical & Electronics Engineer
  • 21. Matrices (con’t…) Matrix Addressing: -- matrixname(row, column) -- colon may be used in place of a row or column reference to select the entire row or column. recall: Example: 21 recall: f = 1 2 3 4 5 6 h = 2 4 6 1 3 5 Example: >> f(2,3) ans = 6 >> h(:,1) ans = 2 1 ANIL MAURYA Electrical & Electronics Engineer
  • 22. Matrices (con’t…) Some useful commands: zeros(n) zeros(m,n) ones(n) returns a n x n matrix of zeros returns a m x n matrix of zeros returns a n x n matrix of ones 22 ones(n) ones(m,n) size (A) length(A) returns a n x n matrix of ones returns a m x n matrix of ones for a m x n matrix A, returns the row vector [m,n] containing the number of rows and columns in matrix. returns the larger of the number of rows or columns in A. ANIL MAURYA Electrical & Electronics Engineer
  • 23. Matrices (con’t…) TransposeTranspose B = A’B = A’ Identity MatrixIdentity Matrix eye(n)eye(n) returns an n x n identity matrixreturns an n x n identity matrix eye(m,n)eye(m,n) returns an m x n matrix with ones on the mainreturns an m x n matrix with ones on the main diagonal and zeros elsewhere.diagonal and zeros elsewhere. Addition and subtractionAddition and subtraction C = A + BC = A + B more commands 23 Addition and subtractionAddition and subtraction C = A + BC = A + B C = AC = A –– BB Scalar MultiplicationScalar Multiplication B =B = ααA, whereA, where αα is a scalar.is a scalar. Matrix MultiplicationMatrix Multiplication C = A*BC = A*B Matrix InverseMatrix Inverse B = inv(A), A must be a square matrix in this case.B = inv(A), A must be a square matrix in this case. rank (A)rank (A) returns the rank of the matrix A.returns the rank of the matrix A. Matrix PowersMatrix Powers B = A.^2B = A.^2 squares each element in the matrixsquares each element in the matrix C = A * AC = A * A computes A*A, and A must be a square matrix.computes A*A, and A must be a square matrix. DeterminantDeterminant det (A), and A must be a square matrix.det (A), and A must be a square matrix. A, B, C are matrices, and m, n, α are scalars. ANIL MAURYA Electrical & Electronics Engineer
  • 24. Solutions to Systems of Linear Equations Example: a system of 3 linear equations with 3 unknowns (x1, x2, x3): 3x1 + 2x2 – x3 = 10 -x1 + 3x2 + 2x3 = 5 x1 – x2 – x3 = -1  −123 x 10 Let : 24 Then, the system can be described as: Ax = b           −− − − = 111 231 123 A           = 3 2 1 x x x x           − = 1 5 10 b ANIL MAURYA Electrical & Electronics Engineer
  • 25. Solutions to Systems of Linear Equations (con’t…) Solution by Matrix Inverse: Ax = b A-1Ax = A-1b x = A-1b MATLAB: >> A = [ 3 2 -1; -1 3 2; 1 -1 -1]; Solution by Matrix Division:Solution by Matrix Division: The solution to the equationThe solution to the equation Ax = bAx = b can be computed usingcan be computed using left divisionleft division.. MATLAB: >> A = [ 3 2 -1; -1 3 2; 1 -1 -1];>> A = [ 3 2 -1; -1 3 2; 1 -1 -1]; >> b = [ 10; 5; -1]; >> x = inv(A)*b x = -2.0000 5.0000 -6.0000 25 Answer: x1 = -2, x2 = 5, x3 = -6 Answer: x1 = -2, x2 = 5, x3 = -6 NOTE: left division: Ab b ÷ A right division: x/y x ÷ y >> A = [ 3 2 -1; -1 3 2; 1 -1 -1]; >> b = [ 10; 5; -1]; >> x = Ab x = -2.0000 5.0000 -6.0000 ANIL MAURYA Electrical & Electronics Engineer
  • 26. 26ANIL MAURYA Electrical & Electronics Engineer
  • 27. 27ANIL MAURYA Electrical & Electronics Engineer
  • 28. 28ANIL MAURYA Electrical & Electronics Engineer
  • 29. 29ANIL MAURYA Electrical & Electronics Engineer
  • 30. 30ANIL MAURYA Electrical & Electronics Engineer
  • 31. 31ANIL MAURYA Electrical & Electronics Engineer
  • 32. 32ANIL MAURYA Electrical & Electronics Engineer
  • 33. 33ANIL MAURYA Electrical & Electronics Engineer
  • 34. 34ANIL MAURYA Electrical & Electronics Engineer
  • 35. 35ANIL MAURYA Electrical & Electronics Engineer
  • 36. 36ANIL MAURYA Electrical & Electronics Engineer
  • 37. 37ANIL MAURYA Electrical & Electronics Engineer
  • 38. 38ANIL MAURYA Electrical & Electronics Engineer
  • 39. 39ANIL MAURYA Electrical & Electronics Engineer
  • 40. 40ANIL MAURYA Electrical & Electronics Engineer
  • 41. 41ANIL MAURYA Electrical & Electronics Engineer
  • 42. 42ANIL MAURYA Electrical & Electronics Engineer
  • 43. 43ANIL MAURYA Electrical & Electronics Engineer
  • 44. 44ANIL MAURYA Electrical & Electronics Engineer
  • 45. 45ANIL MAURYA Electrical & Electronics Engineer
  • 46. 46ANIL MAURYA Electrical & Electronics Engineer
  • 47. 47ANIL MAURYA Electrical & Electronics Engineer