SlideShare a Scribd company logo
EngMahmoud Hussein
Vectors
MATLAB has two forms of vectors:
 Row vectors
 Column vector
 Row vectors: they are lists of numbers separated by either commas or
spaces.
 The number of entries is known as the"length" of the vector The
entries must be enclosed in square brackets.
v=[1 3,sqrt(25)];
Vectors
 Examples:
 v = [ 1 3, sqrt(5)]
 v2 = [3+ 4 5]
 v3 = [3 +4 5] � is v2=v3 ?!!!!!
 We can do certain arithmetic operations with vectors of the same length
(v , v3)
 Try adding v and v2.
Vectors
Suppose we want a vector starting from 1 up to 100 with increments of
one (i.e. 1 2…100).
Write 100 elements � time consuming process.
 An easy way: v=[1:100].
 Generally a : b : c produces a vector of entries
 Starting with the value a,
 Incrementing by the value b
 Until it gets to c.
 Example: 0.32:0.1:0.6
Vectors
 So far, we have two methods for declaration:
 X=[element1 element2 element3 ……. ]
 (start : step : end)
 Another declaration of the vector is:
 Z=linspace(O,1O,11) � (start, end, no. of points)
 Linear space
 Increment = (end - start)/(N-1)
 If X is a vector, then Y=sin(X), is also a vector with the same dimensions.
this direct relation between x,y
Coloum Vectors
 These have similar constructs to row vectors.
 But, entries are separated by ";" instead of ",".
 Or, write each element in separate row.
 >>x=[2;3;4];
 X=2
3
4
 >>x=[2
3
4]
Vectors Transposing
 We can convert a row vector into a column vector (and vice versa) by a
process called transposing.
 If H is a row vector, then
 H' is a column vector, with elements of H.
 Try it.
 >>x=[2;3;4]; x’
 >>x=[2 3 4]; x’
 If x is a complex vector, then x' gives the complex conjugate transpose
of x.
Operations on Vectors
Operations on Vectors
vectors notes
 Assume r = [1:2:6, -1:-2:-7];
 >>r^2
 >>r.^2
 to get the square of each element we use: X.A2 NOT XA2
 Where (.) means element by element and no care for dimension.
vectors multipulication
 What is the difference?
Z = X*Y � single valued
Z = X.*Y � vector!
Assume x=[1 2 3 4]
y=[5 6 7 8]
plotting two vectors
 Note: minimizing the step size will lead to very smooth curve for the
relationship and vice versa.
 Simply we use the plot order to plot the vectors against each other.
 Plot (indep_var , depen_var)
 >>x=[-2*pi:0.1:2*pi];
 >>y=sin(x);
 >>plot(x,y)
plotting two vectors
plotting two vectors
 Note: no direct relation bt. Month and Temp
 Solution:
 >> Month=[1:1:12];
 >> Temperature=[ 17 19 22 24 27 30 34 35 31 26 23 20];
 >> plot(Month,Temperature)
 The result is a continuous curve, but do we need that really in this
application?
 Use stem(Month,Temperature) for discrete sample plotting.
Plotting two vectors
 Strings is declared as follows:
 t1 = 'A' � 1-by-1 character array.
 t2 = 'BCDE' � 1-by-4 character array Powerful operations can be
performed using just one or two commands.
 If our string contains quotes (you're the one)
 >> str = 'you''re the one' � use 2 quotes
 You can convert between ASCII values and the characters they
represent using the double and char command.
Strings on matlab
 >>Alpha=‘mahmoud’;
 >>num=double(alpha);
 >>char(num)
ans= mahmoud
Strings on matlab
matrices
 Row and Column vectors are special cases of matrices.
 An m x n matrix is a rectangular array of numbers having m rows and
n columns.
 A=[1 2 3
4 5 6]
Typing matrices
 To type a matrix into MATLAB you must:
 Begin with a square bracket [
 Separate elements in a row with commas or space
 Use a semicolon ";" to separate rows
 End the matrix with another square bracket ].
 Example: a=[123;456]
 MATLAB responds with:
a=1 2 3
4 5 6
Concatenating Matrices
 Matrices can be made up of sub-matrices:
 Try this:
Matrix replication
 The repmat function can be used to replicate a matrix.
 repmat( matrix, No. replecated rows, No. rep columns);
 Try this:
Matrix generator
Operation on matrices
Operation on matrices
Operation on matrices
Operation on matrices
Extracting bits of matrix
 Given Matrix J, what is the result of the following?
j=1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
J(1,1), J(2,3), J(4,3), J(:,3), J(4,:), J(1:3,2:3),
Deleting row or coloum
 Let a is a predefined matrix
 To delete row number M, write:
a(M,:) = []
 To delete column number N, write:
a(:,N) = []
Solving linear equation
 Suppose that you would like to solve the following system of equations:
 2X+Y-Z=6
 X-Y-Z=-3
 X+2Y-3Z=-9
 In matrix form, you can write:
Solving linear equation

More Related Content

What's hot

Piecewise Functions in Matlab
Piecewise Functions in MatlabPiecewise Functions in Matlab
Piecewise Functions in Matlab
Jorge Jasso
 
Module#8 notes
Module#8 notesModule#8 notes
Module#8 notes
REYEMMANUELILUMBA
 
Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4
Randa Elanwar
 
Polynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLABPolynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLAB
Shameer Ahmed Koya
 
5 octave tutorial
5 octave tutorial5 octave tutorial
5 octave tutorial
TanmayVijay1
 
Programming Assignment Help
Programming Assignment HelpProgramming Assignment Help
Programming Assignment Help
Programming Homework Help
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and Polynomial
Aroosa Rajput
 
All pair shortest path
All pair shortest pathAll pair shortest path
All pair shortest path
Arafat Hossan
 
Piecewise Functions
Piecewise FunctionsPiecewise Functions
Piecewise Functionsswartzje
 
Bisection method
Bisection methodBisection method
Bisection method
Tirth Parmar
 
Bisection method
Bisection methodBisection method
Bisection method
Md. Mujahid Islam
 
Scilab - Piecewise Functions
Scilab - Piecewise FunctionsScilab - Piecewise Functions
Scilab - Piecewise Functions
Jorge Jasso
 
Fourier Transform Assignment Help
Fourier Transform Assignment HelpFourier Transform Assignment Help
Fourier Transform Assignment Help
Matlab Assignment Experts
 
Intro to Matlab programming
Intro to Matlab programmingIntro to Matlab programming
Intro to Matlab programming
Ahmed Moawad
 
MATLAB for Technical Computing
MATLAB for Technical ComputingMATLAB for Technical Computing
MATLAB for Technical Computing
Naveed Rehman
 
Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)
Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)
Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)
Minhas Kamal
 
Bisection Method
Bisection Method Bisection Method
Bisection Method
Pritam Shil
 
Assignment problem
Assignment problemAssignment problem
Assignment problem
Anggy Herny Anggraeni
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsKetan Jani
 

What's hot (20)

Piecewise Functions in Matlab
Piecewise Functions in MatlabPiecewise Functions in Matlab
Piecewise Functions in Matlab
 
Module#8 notes
Module#8 notesModule#8 notes
Module#8 notes
 
Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4
 
Polynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLABPolynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLAB
 
5 octave tutorial
5 octave tutorial5 octave tutorial
5 octave tutorial
 
Programming Assignment Help
Programming Assignment HelpProgramming Assignment Help
Programming Assignment Help
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and Polynomial
 
All pair shortest path
All pair shortest pathAll pair shortest path
All pair shortest path
 
Piecewise Functions
Piecewise FunctionsPiecewise Functions
Piecewise Functions
 
Bisection method
Bisection methodBisection method
Bisection method
 
Bisection method
Bisection methodBisection method
Bisection method
 
Scilab - Piecewise Functions
Scilab - Piecewise FunctionsScilab - Piecewise Functions
Scilab - Piecewise Functions
 
Fourier Transform Assignment Help
Fourier Transform Assignment HelpFourier Transform Assignment Help
Fourier Transform Assignment Help
 
Matlab cheatsheet
Matlab cheatsheetMatlab cheatsheet
Matlab cheatsheet
 
Intro to Matlab programming
Intro to Matlab programmingIntro to Matlab programming
Intro to Matlab programming
 
MATLAB for Technical Computing
MATLAB for Technical ComputingMATLAB for Technical Computing
MATLAB for Technical Computing
 
Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)
Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)
Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)
 
Bisection Method
Bisection Method Bisection Method
Bisection Method
 
Assignment problem
Assignment problemAssignment problem
Assignment problem
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 

Viewers also liked

Where are things in 3 d
Where are things in 3 dWhere are things in 3 d
Where are things in 3 d
Mahmoud Hussein
 
Robotics lecture 3
Robotics lecture 3Robotics lecture 3
Robotics lecture 3
Mahmoud Hussein
 
Where are things in 2 d
Where are things in 2 dWhere are things in 2 d
Where are things in 2 d
Mahmoud Hussein
 
Robotics lec 6
Robotics lec 6Robotics lec 6
Robotics lec 6
Mahmoud Hussein
 
Automation lecture5
Automation lecture5Automation lecture5
Automation lecture5
Mahmoud Hussein
 
Robotics lec7
Robotics lec7Robotics lec7
Robotics lec7
Mahmoud Hussein
 
Automation lecture1
Automation lecture1Automation lecture1
Automation lecture1
Mahmoud Hussein
 
Pneumatic control
Pneumatic controlPneumatic control
Pneumatic control
Mahmoud Hussein
 
Forward kinematics
Forward kinematicsForward kinematics
Forward kinematics
Mahmoud Hussein
 
Automation lecture 6
Automation lecture 6Automation lecture 6
Automation lecture 6
Mahmoud Hussein
 
Dh parameters robotics
Dh  parameters roboticsDh  parameters robotics
Dh parameters robotics
Mahmoud Hussein
 
Robotics lec 5
Robotics lec 5Robotics lec 5
Robotics lec 5
Mahmoud Hussein
 
Automation lec4
Automation lec4Automation lec4
Automation lec4
Mahmoud Hussein
 
Automation lec4
Automation lec4Automation lec4
Automation lec4
Mahmoud Hussein
 
plc introduction
plc introductionplc introduction
plc introduction
Mahmoud Hussein
 
Use case diagrams
Use case diagramsUse case diagrams
Use case diagrams
Ahmed Elshahat Mohamed
 
software engineering
 software engineering software engineering
software engineering
Ahmed Elshahat Mohamed
 
Promo Curs Oratoria I 2008 09
Promo Curs Oratoria I 2008 09Promo Curs Oratoria I 2008 09
Promo Curs Oratoria I 2008 091977bcn
 
Top 8 office executive resume samples
Top 8 office executive resume samplesTop 8 office executive resume samples
Top 8 office executive resume samplesjomporis
 
SXTXState Final Presentation
SXTXState Final PresentationSXTXState Final Presentation
SXTXState Final Presentation
Cindy Royal
 

Viewers also liked (20)

Where are things in 3 d
Where are things in 3 dWhere are things in 3 d
Where are things in 3 d
 
Robotics lecture 3
Robotics lecture 3Robotics lecture 3
Robotics lecture 3
 
Where are things in 2 d
Where are things in 2 dWhere are things in 2 d
Where are things in 2 d
 
Robotics lec 6
Robotics lec 6Robotics lec 6
Robotics lec 6
 
Automation lecture5
Automation lecture5Automation lecture5
Automation lecture5
 
Robotics lec7
Robotics lec7Robotics lec7
Robotics lec7
 
Automation lecture1
Automation lecture1Automation lecture1
Automation lecture1
 
Pneumatic control
Pneumatic controlPneumatic control
Pneumatic control
 
Forward kinematics
Forward kinematicsForward kinematics
Forward kinematics
 
Automation lecture 6
Automation lecture 6Automation lecture 6
Automation lecture 6
 
Dh parameters robotics
Dh  parameters roboticsDh  parameters robotics
Dh parameters robotics
 
Robotics lec 5
Robotics lec 5Robotics lec 5
Robotics lec 5
 
Automation lec4
Automation lec4Automation lec4
Automation lec4
 
Automation lec4
Automation lec4Automation lec4
Automation lec4
 
plc introduction
plc introductionplc introduction
plc introduction
 
Use case diagrams
Use case diagramsUse case diagrams
Use case diagrams
 
software engineering
 software engineering software engineering
software engineering
 
Promo Curs Oratoria I 2008 09
Promo Curs Oratoria I 2008 09Promo Curs Oratoria I 2008 09
Promo Curs Oratoria I 2008 09
 
Top 8 office executive resume samples
Top 8 office executive resume samplesTop 8 office executive resume samples
Top 8 office executive resume samples
 
SXTXState Final Presentation
SXTXState Final PresentationSXTXState Final Presentation
SXTXState Final Presentation
 

Similar to Lecture two

1. Introduction.pptx
1. Introduction.pptx1. Introduction.pptx
1. Introduction.pptx
SungaleliYuen
 
Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functions
joellivz
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd Esa
Mohd Esa
 
Digital communication lab lectures
Digital communication lab  lecturesDigital communication lab  lectures
Digital communication lab lectures
marwaeng
 
COMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptxCOMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptx
imman gwu
 
2. Chap 1.pptx
2. Chap 1.pptx2. Chap 1.pptx
2. Chap 1.pptx
HassanShah396906
 
Tutorial 2
Tutorial     2Tutorial     2
Tutorial 2
Mohamed Yaser
 
Basic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptxBasic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptx
PremanandS3
 
Matlab Overviiew 2
Matlab Overviiew 2Matlab Overviiew 2
Matlab Overviiew 2
Nazim Naeem
 
EPE821_Lecture3.pptx
EPE821_Lecture3.pptxEPE821_Lecture3.pptx
EPE821_Lecture3.pptx
Ihtisham Uddin
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
raghav415187
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginners
Murshida ck
 
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
khalid Shah
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
naveen_setty
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
aboma2hawi
 
Introduction to matlab chapter2 by Dr.Bashir m. sa'ad.pdf
Introduction to matlab chapter2 by Dr.Bashir m. sa'ad.pdfIntroduction to matlab chapter2 by Dr.Bashir m. sa'ad.pdf
Introduction to matlab chapter2 by Dr.Bashir m. sa'ad.pdf
YasirMuhammadlawan
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptx
Devaraj Chilakala
 
Matlab Tutorial
Matlab TutorialMatlab Tutorial
Matlab Tutorial
Ahmad Siddiq
 

Similar to Lecture two (20)

1. Introduction.pptx
1. Introduction.pptx1. Introduction.pptx
1. Introduction.pptx
 
Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functions
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd Esa
 
Digital communication lab lectures
Digital communication lab  lecturesDigital communication lab  lectures
Digital communication lab lectures
 
COMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptxCOMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptx
 
2. Chap 1.pptx
2. Chap 1.pptx2. Chap 1.pptx
2. Chap 1.pptx
 
Tutorial 2
Tutorial     2Tutorial     2
Tutorial 2
 
Basic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptxBasic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptx
 
bobok
bobokbobok
bobok
 
Matlab Overviiew 2
Matlab Overviiew 2Matlab Overviiew 2
Matlab Overviiew 2
 
EPE821_Lecture3.pptx
EPE821_Lecture3.pptxEPE821_Lecture3.pptx
EPE821_Lecture3.pptx
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginners
 
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_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
 
Introduction to matlab chapter2 by Dr.Bashir m. sa'ad.pdf
Introduction to matlab chapter2 by Dr.Bashir m. sa'ad.pdfIntroduction to matlab chapter2 by Dr.Bashir m. sa'ad.pdf
Introduction to matlab chapter2 by Dr.Bashir m. sa'ad.pdf
 
Lec2
Lec2Lec2
Lec2
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptx
 
Matlab Tutorial
Matlab TutorialMatlab Tutorial
Matlab Tutorial
 

More from Mahmoud Hussein

07 modelling.electric.motors
07 modelling.electric.motors07 modelling.electric.motors
07 modelling.electric.motors
Mahmoud Hussein
 
Dc dc converter
Dc dc converterDc dc converter
Dc dc converter
Mahmoud Hussein
 
08 pid.controller
08 pid.controller08 pid.controller
08 pid.controller
Mahmoud Hussein
 
06 control.systems
06 control.systems06 control.systems
06 control.systems
Mahmoud Hussein
 
05 tuning.pid.controllers
05 tuning.pid.controllers05 tuning.pid.controllers
05 tuning.pid.controllers
Mahmoud Hussein
 
02 physical.system.modelling mechanical.systems.
02 physical.system.modelling mechanical.systems.02 physical.system.modelling mechanical.systems.
02 physical.system.modelling mechanical.systems.
Mahmoud Hussein
 
03 dynamic.system.
03 dynamic.system.03 dynamic.system.
03 dynamic.system.
Mahmoud Hussein
 
Lecture 02 laplace transformation
Lecture 02 laplace transformationLecture 02 laplace transformation
Lecture 02 laplace transformation
Mahmoud Hussein
 
Model based design-Hardware in loop-software in loop
Model based design-Hardware in loop-software in loopModel based design-Hardware in loop-software in loop
Model based design-Hardware in loop-software in loop
Mahmoud Hussein
 
Ac drive basics
Ac drive basicsAc drive basics
Ac drive basics
Mahmoud Hussein
 
MPI Communication
MPI CommunicationMPI Communication
MPI Communication
Mahmoud Hussein
 
Analogue Module
Analogue ModuleAnalogue Module
Analogue Module
Mahmoud Hussein
 
Function Block & Organization Block
Function Block & Organization BlockFunction Block & Organization Block
Function Block & Organization Block
Mahmoud Hussein
 
Data Block
Data BlockData Block
Data Block
Mahmoud Hussein
 
Declaration Table
Declaration TableDeclaration Table
Declaration Table
Mahmoud Hussein
 
Math operation
Math operationMath operation
Math operation
Mahmoud Hussein
 
Industrial communication
Industrial communicationIndustrial communication
Industrial communication
Mahmoud Hussein
 
Computer vision
Computer visionComputer vision
Computer vision
Mahmoud Hussein
 

More from Mahmoud Hussein (20)

07 modelling.electric.motors
07 modelling.electric.motors07 modelling.electric.motors
07 modelling.electric.motors
 
Dc dc converter
Dc dc converterDc dc converter
Dc dc converter
 
08 pid.controller
08 pid.controller08 pid.controller
08 pid.controller
 
06 control.systems
06 control.systems06 control.systems
06 control.systems
 
05 tuning.pid.controllers
05 tuning.pid.controllers05 tuning.pid.controllers
05 tuning.pid.controllers
 
02 physical.system.modelling mechanical.systems.
02 physical.system.modelling mechanical.systems.02 physical.system.modelling mechanical.systems.
02 physical.system.modelling mechanical.systems.
 
03 dynamic.system.
03 dynamic.system.03 dynamic.system.
03 dynamic.system.
 
Lecture 02 laplace transformation
Lecture 02 laplace transformationLecture 02 laplace transformation
Lecture 02 laplace transformation
 
Model based design-Hardware in loop-software in loop
Model based design-Hardware in loop-software in loopModel based design-Hardware in loop-software in loop
Model based design-Hardware in loop-software in loop
 
Ac drive basics
Ac drive basicsAc drive basics
Ac drive basics
 
Velocity kinematics
Velocity kinematicsVelocity kinematics
Velocity kinematics
 
MPI Communication
MPI CommunicationMPI Communication
MPI Communication
 
ERROR
ERRORERROR
ERROR
 
Analogue Module
Analogue ModuleAnalogue Module
Analogue Module
 
Function Block & Organization Block
Function Block & Organization BlockFunction Block & Organization Block
Function Block & Organization Block
 
Data Block
Data BlockData Block
Data Block
 
Declaration Table
Declaration TableDeclaration Table
Declaration Table
 
Math operation
Math operationMath operation
Math operation
 
Industrial communication
Industrial communicationIndustrial communication
Industrial communication
 
Computer vision
Computer visionComputer vision
Computer vision
 

Recently uploaded

road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 

Recently uploaded (20)

road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 

Lecture two

  • 2. Vectors MATLAB has two forms of vectors:  Row vectors  Column vector  Row vectors: they are lists of numbers separated by either commas or spaces.  The number of entries is known as the"length" of the vector The entries must be enclosed in square brackets. v=[1 3,sqrt(25)];
  • 3. Vectors  Examples:  v = [ 1 3, sqrt(5)]  v2 = [3+ 4 5]  v3 = [3 +4 5] � is v2=v3 ?!!!!!  We can do certain arithmetic operations with vectors of the same length (v , v3)  Try adding v and v2.
  • 4. Vectors Suppose we want a vector starting from 1 up to 100 with increments of one (i.e. 1 2…100). Write 100 elements � time consuming process.  An easy way: v=[1:100].  Generally a : b : c produces a vector of entries  Starting with the value a,  Incrementing by the value b  Until it gets to c.  Example: 0.32:0.1:0.6
  • 5. Vectors  So far, we have two methods for declaration:  X=[element1 element2 element3 ……. ]  (start : step : end)  Another declaration of the vector is:  Z=linspace(O,1O,11) � (start, end, no. of points)  Linear space  Increment = (end - start)/(N-1)  If X is a vector, then Y=sin(X), is also a vector with the same dimensions. this direct relation between x,y
  • 6. Coloum Vectors  These have similar constructs to row vectors.  But, entries are separated by ";" instead of ",".  Or, write each element in separate row.  >>x=[2;3;4];  X=2 3 4  >>x=[2 3 4]
  • 7. Vectors Transposing  We can convert a row vector into a column vector (and vice versa) by a process called transposing.  If H is a row vector, then  H' is a column vector, with elements of H.  Try it.  >>x=[2;3;4]; x’  >>x=[2 3 4]; x’  If x is a complex vector, then x' gives the complex conjugate transpose of x.
  • 10. vectors notes  Assume r = [1:2:6, -1:-2:-7];  >>r^2  >>r.^2  to get the square of each element we use: X.A2 NOT XA2  Where (.) means element by element and no care for dimension.
  • 11. vectors multipulication  What is the difference? Z = X*Y � single valued Z = X.*Y � vector! Assume x=[1 2 3 4] y=[5 6 7 8]
  • 12. plotting two vectors  Note: minimizing the step size will lead to very smooth curve for the relationship and vice versa.  Simply we use the plot order to plot the vectors against each other.  Plot (indep_var , depen_var)  >>x=[-2*pi:0.1:2*pi];  >>y=sin(x);  >>plot(x,y)
  • 14. plotting two vectors  Note: no direct relation bt. Month and Temp  Solution:  >> Month=[1:1:12];  >> Temperature=[ 17 19 22 24 27 30 34 35 31 26 23 20];  >> plot(Month,Temperature)  The result is a continuous curve, but do we need that really in this application?  Use stem(Month,Temperature) for discrete sample plotting.
  • 16.  Strings is declared as follows:  t1 = 'A' � 1-by-1 character array.  t2 = 'BCDE' � 1-by-4 character array Powerful operations can be performed using just one or two commands.  If our string contains quotes (you're the one)  >> str = 'you''re the one' � use 2 quotes  You can convert between ASCII values and the characters they represent using the double and char command. Strings on matlab
  • 17.  >>Alpha=‘mahmoud’;  >>num=double(alpha);  >>char(num) ans= mahmoud Strings on matlab
  • 18. matrices  Row and Column vectors are special cases of matrices.  An m x n matrix is a rectangular array of numbers having m rows and n columns.  A=[1 2 3 4 5 6]
  • 19. Typing matrices  To type a matrix into MATLAB you must:  Begin with a square bracket [  Separate elements in a row with commas or space  Use a semicolon ";" to separate rows  End the matrix with another square bracket ].  Example: a=[123;456]  MATLAB responds with: a=1 2 3 4 5 6
  • 20. Concatenating Matrices  Matrices can be made up of sub-matrices:  Try this:
  • 21. Matrix replication  The repmat function can be used to replicate a matrix.  repmat( matrix, No. replecated rows, No. rep columns);  Try this:
  • 27. Extracting bits of matrix  Given Matrix J, what is the result of the following? j=1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 J(1,1), J(2,3), J(4,3), J(:,3), J(4,:), J(1:3,2:3),
  • 28. Deleting row or coloum  Let a is a predefined matrix  To delete row number M, write: a(M,:) = []  To delete column number N, write: a(:,N) = []
  • 29. Solving linear equation  Suppose that you would like to solve the following system of equations:  2X+Y-Z=6  X-Y-Z=-3  X+2Y-3Z=-9  In matrix form, you can write: