SlideShare a Scribd company logo
1 of 38
This document is intended for internal use only and shall not be distributed outside of GUtech in Oman
Numerical Methods for Engineers and Scientists
Lecturer: Assistant Prof. Dr. AYDIN AZIZI
Slide 2
Copyright © 2014 John Wiley & Sons, Inc. All rights reserved.
Third Edition
Amos Gilat • Vish Subramaniam
Numerical Methods
for
Engineers and Scientists
Slide 3
Lecturer: Assistant Prof. Dr. Aydin Azizi
Introduction to MATLAB
Lecturer: Assistant Prof. Dr. Aydin Azizi
Slide 4
Lecturer: Assistant Prof. Dr. Aydin Azizi
Example of MATLAB Release 13 desktop
Lecturer: Assistant Prof. Dr. Aydin Azizi
Slide 5
Lecturer: Assistant Prof. Dr. Aydin Azizi
Variables
– Vectors and Matrices –
• ALL variables are matrices
Variables
•They are case–sensitive i.e. x  X
•Their names can contain up to 31 characters
•Must start with a letter
•Variables are stored in workspace
e.g. 1 x 1 4 x 1 1 x 4 2 x 4






4239
6512 7123












3
9
2
3
 4
Lecturer: Assistant Prof. Dr. Aydin Azizi
Slide 6
Lecturer: Assistant Prof. Dr. Aydin Azizi
How do we assign a value to a variable?
>>> v1=3
v1 =
3
>>> i1=4
i1 =
4
>>> R=v1/i1
R =
0.7500
>>>
>>> whos
Name Size Bytes Class
R 1x1 8 double array
i1 1x1 8 double array
v1 1x1 8 double array
Grand total is 3 elements using 24 bytes
>>> who
Your variables are:
R i1 v1
>>>
Lecturer: Assistant Prof. Dr. Aydin Azizi
Slide 7
Lecturer: Assistant Prof. Dr. Aydin Azizi
How do we assign values to vectors?
>>> A = [1 2 3 4 5]
A =
1 2 3 4 5
>>>
>>> B = [10;12;14;16;18]
B =
10
12
14
16
18
>>>
A row vector values
are separated by
spaces
 54321A 

















18
16
14
12
10
B
A column vector
values are
separated by
semi–colon (;)
Lecturer: Assistant Prof. Dr. Aydin Azizi
Slide 8
Lecturer: Assistant Prof. Dr. Aydin Azizi
How do we assign values to vectors?
• If we want to construct a vector of, say, 100 elements between 0 and 2 – linspace
>>> c1 = linspace(0,(2*pi),100);
>>> whos
Name Size Bytes Class
c1 1x100 800 double array
Grand total is 100 elements using 800 bytes
>>>
Lecturer: Assistant Prof. Dr. Aydin Azizi
Slide 9
Lecturer: Assistant Prof. Dr. Aydin Azizi
How do we assign values to vectors?
If we want to construct an array of, say, 100 elements between 0 and 2
– colon notation
>>> c2 = (0:0.0201:2)*pi;
>>> whos
Name Size Bytes Class
c1 1x100 800 double array
c2 1x100 800 double array
Grand total is 200 elements using 1600 bytes
>>>
Lecturer: Assistant Prof. Dr. Aydin Azizi
Slide 10
Lecturer: Assistant Prof. Dr. Aydin Azizi
How do we assign values to matrices ?
Columns separated by
space or a comma
Rows separated by
semi-colon
>>> A=[1 2 3;4 5 6;7 8 9]
A =
1 2 3
4 5 6
7 8 9
>>>










987
654
321
Lecturer: Assistant Prof. Dr. Aydin Azizi
Slide 11
Lecturer: Assistant Prof. Dr. Aydin Azizi
How do we access elements in a matrix or a vector?
>>> A(2,3)
ans =
6
>>> A(:,3)
ans =
3
6
9
>>> A(1,:)
ans =
1 2 3
>>> A(2,:)
ans =
4 5 6
Lecturer: Assistant Prof. Dr. Aydin Azizi
Slide 12
Lecturer: Assistant Prof. Dr. Aydin Azizi
Some special variables
pi ()
inf (e.g. 1/0)
i, j ( )1
>>> 1/0
Warning: Divide by zero.
ans =
Inf
>>> pi
ans =
3.1416
>>> i
ans =
0+ 1.0000i
Lecturer: Assistant Prof. Dr. Aydin Azizi
Slide 13
Lecturer: Assistant Prof. Dr. Aydin Azizi
Arithmetic operations – Matrices
Performing operations to every entry in a matrix
Add and subtract>>> A=[1 2 3;4 5 6;7 8
9]
A =
1 2 3
4 5 6
7 8 9
>>>
>>> A+3
ans =
4 5 6
7 8 9
10 11 12
>>> A-2
ans =
-1 0 1
2 3 4
5 6 7
Lecturer: Assistant Prof. Dr. Aydin Azizi
Slide 14
Lecturer: Assistant Prof. Dr. Aydin Azizi
Arithmetic operations – Matrices
Performing operations to every entry in a matrix
Multiply and divide>>> A=[1 2 3;4 5 6;7 8 9]
A =
1 2 3
4 5 6
7 8 9
>>>
>>> A*2
ans =
2 4 6
8 10 12
14 16 18
>>> A/3
ans =
0.3333 0.6667 1.0000
1.3333 1.6667 2.0000
2.3333 2.6667 3.0000
Lecturer: Assistant Prof. Dr. Aydin Azizi
Slide 15
Lecturer: Assistant Prof. Dr. Aydin Azizi
Arithmetic operations – Matrices
Performing operations to every entry in a matrix
Power
>>> A=[1 2 3;4 5 6;7 8 9]
A =
1 2 3
4 5 6
7 8 9
>>>
A^2 = A * A
To square every element in A, use
the element–wise operator .^
>>> A.^2
ans =
1 4 9
16 25 36
49 64 81
>>> A^2
ans =
30 36 42
66 81 96
102 126 150
Lecturer: Assistant Prof. Dr. Aydin Azizi
Slide 16
Lecturer: Assistant Prof. Dr. Aydin Azizi
Performing operations between matrices
>>> A=[1 2 3;4 5 6;7 8 9]
A =
1 2 3
4 5 6
7 8 9
>>> B=[1 1 1;2 2 2;3 3 3]
B =
1 1 1
2 2 2
3 3 3
A*B 



















333
222
111
987
654
321
A.*B










3x93x83x7
2x62x52x4
1x31x21x1










272421
12108
321
=
=










505050
323232
141414
Arithmetic operations – Matrices
Lecturer: Assistant Prof. Dr. Aydin Azizi
Slide 17
Lecturer: Assistant Prof. Dr. Aydin Azizi
Roots- Logarithms
Slide 18
Lecturer: Assistant Prof. Dr. Aydin Azizi
Random Number
Slide 19
Lecturer: Assistant Prof. Dr. Aydin Azizi
Random Real Number
Slide 20
Lecturer: Assistant Prof. Dr. Aydin Azizi
Random Integer Number
Slide 21
Lecturer: Assistant Prof. Dr. Aydin Azizi
Practice
Slide 22
Lecturer: Assistant Prof. Dr. Aydin Azizi
Characters and Encoding
Slide 23
Lecturer: Assistant Prof. Dr. Aydin Azizi
Characters and Encoding
Slide 24
Lecturer: Assistant Prof. Dr. Aydin Azizi
Characters and Encoding
Slide 25
Lecturer: Assistant Prof. Dr. Aydin Azizi
Practice
Slide 26
Lecturer: Assistant Prof. Dr. Aydin Azizi
Relational Expressions
Slide 27
Lecturer: Assistant Prof. Dr. Aydin Azizi
Relational Expressions
Slide 28
Lecturer: Assistant Prof. Dr. Aydin Azizi
Relational Expressions
Slide 29
Lecturer: Assistant Prof. Dr. Aydin Azizi
Logical Operators
Slide 30
Lecturer: Assistant Prof. Dr. Aydin Azizi
Logical Operators
Slide 31
Lecturer: Assistant Prof. Dr. Aydin Azizi
Logical Operators
Slide 32
Lecturer: Assistant Prof. Dr. Aydin Azizi
Truth Table for Logical Operators
Slide 33
Lecturer: Assistant Prof. Dr. Aydin Azizi
Logical Error
Slide 34
Lecturer: Assistant Prof. Dr. Aydin Azizi
Logical Error
Slide 35
Lecturer: Assistant Prof. Dr. Aydin Azizi
Practice
Slide 36
Lecturer: Assistant Prof. Dr. Aydin Azizi
While Loop
count = 0;
number = 8;
while number > 3
number = number - 2
count = count+1
end
Slide 37
Lecturer: Assistant Prof. Dr. Aydin Azizi
FOR Loop
mat=rand(5,6)
[r c] = size(mat)
for i = 1:r
for j = 1:c
mat(i,j) = mat(i,j) * 2
end
end
Slide 38
Lecturer: Assistant Prof. Dr. Aydin Azizi
IF Loop
x=rand(10,1);
v = [ ]
for i = 1:length(x)
if x(i) > 0
v = [v i]
end
end

More Related Content

Viewers also liked

СПЕЦПРОЕКТ ММСО-2017. ФОРУМ «Негосударственное дополнительное образование»
СПЕЦПРОЕКТ ММСО-2017. ФОРУМ «Негосударственное дополнительное образование»СПЕЦПРОЕКТ ММСО-2017. ФОРУМ «Негосударственное дополнительное образование»
СПЕЦПРОЕКТ ММСО-2017. ФОРУМ «Негосударственное дополнительное образование»edexpert
 
Computer applications lab manual
Computer applications lab manualComputer applications lab manual
Computer applications lab manualshahid naseem
 
додаток 5. універсали (2)
додаток 5. універсали (2)додаток 5. універсали (2)
додаток 5. універсали (2)solom_nmc
 
Conceptos basicos de probabilidad
Conceptos basicos de probabilidadConceptos basicos de probabilidad
Conceptos basicos de probabilidadJennifer Esquer
 
Amazing likeness
Amazing likenessAmazing likeness
Amazing likenessMaya
 
Programa curricular-educacion-inicial
Programa curricular-educacion-inicialPrograma curricular-educacion-inicial
Programa curricular-educacion-inicialIrene Villanueva
 
Edición de videos
Edición de videosEdición de videos
Edición de videosangief31
 
Presentación biología 1
Presentación biología 1Presentación biología 1
Presentación biología 1Eliana Michel
 
Munu barnabörnin mín tala íslensku
Munu barnabörnin mín tala íslensku Munu barnabörnin mín tala íslensku
Munu barnabörnin mín tala íslensku Gummi Hafsteinsson
 
Di gennaro díaz_duran_presentaciónfinal
Di gennaro díaz_duran_presentaciónfinalDi gennaro díaz_duran_presentaciónfinal
Di gennaro díaz_duran_presentaciónfinalSergio26Duran
 
Blog Ethika Global: "¿Conseguirá el EURUSD llegar a la paridad? (Melchor Arme...
Blog Ethika Global: "¿Conseguirá el EURUSD llegar a la paridad? (Melchor Arme...Blog Ethika Global: "¿Conseguirá el EURUSD llegar a la paridad? (Melchor Arme...
Blog Ethika Global: "¿Conseguirá el EURUSD llegar a la paridad? (Melchor Arme...Ethika Global Consulting
 
Estado da arte em Codificação Criativa
Estado da arte em Codificação CriativaEstado da arte em Codificação Criativa
Estado da arte em Codificação CriativaUTFPR
 
El negocio del SEO y cómo hacer que Google quiera tu web
El negocio del SEO y cómo hacer que Google quiera tu webEl negocio del SEO y cómo hacer que Google quiera tu web
El negocio del SEO y cómo hacer que Google quiera tu webCongreso Turismo Rural
 
Pleura and pleural cavity copy
Pleura and pleural cavity   copyPleura and pleural cavity   copy
Pleura and pleural cavity copyJeevan Kumar
 
Towards Streamlined Technology-driven orchestration for Effective Teaching
Towards Streamlined Technology-driven orchestration for Effective TeachingTowards Streamlined Technology-driven orchestration for Effective Teaching
Towards Streamlined Technology-driven orchestration for Effective TeachingLighton Phiri
 

Viewers also liked (20)

СПЕЦПРОЕКТ ММСО-2017. ФОРУМ «Негосударственное дополнительное образование»
СПЕЦПРОЕКТ ММСО-2017. ФОРУМ «Негосударственное дополнительное образование»СПЕЦПРОЕКТ ММСО-2017. ФОРУМ «Негосударственное дополнительное образование»
СПЕЦПРОЕКТ ММСО-2017. ФОРУМ «Негосударственное дополнительное образование»
 
Computer applications lab manual
Computer applications lab manualComputer applications lab manual
Computer applications lab manual
 
Pmi servizio uc
Pmi servizio   ucPmi servizio   uc
Pmi servizio uc
 
додаток 5. універсали (2)
додаток 5. універсали (2)додаток 5. універсали (2)
додаток 5. універсали (2)
 
Cordless
CordlessCordless
Cordless
 
Conceptos basicos de probabilidad
Conceptos basicos de probabilidadConceptos basicos de probabilidad
Conceptos basicos de probabilidad
 
Amazing likeness
Amazing likenessAmazing likeness
Amazing likeness
 
Programa curricular-educacion-inicial
Programa curricular-educacion-inicialPrograma curricular-educacion-inicial
Programa curricular-educacion-inicial
 
Edición de videos
Edición de videosEdición de videos
Edición de videos
 
Presentación biología 1
Presentación biología 1Presentación biología 1
Presentación biología 1
 
Munu barnabörnin mín tala íslensku
Munu barnabörnin mín tala íslensku Munu barnabörnin mín tala íslensku
Munu barnabörnin mín tala íslensku
 
Di gennaro díaz_duran_presentaciónfinal
Di gennaro díaz_duran_presentaciónfinalDi gennaro díaz_duran_presentaciónfinal
Di gennaro díaz_duran_presentaciónfinal
 
4 matriz 7º a
4 matriz 7º a4 matriz 7º a
4 matriz 7º a
 
Ρομαντισμός
ΡομαντισμόςΡομαντισμός
Ρομαντισμός
 
Blog Ethika Global: "¿Conseguirá el EURUSD llegar a la paridad? (Melchor Arme...
Blog Ethika Global: "¿Conseguirá el EURUSD llegar a la paridad? (Melchor Arme...Blog Ethika Global: "¿Conseguirá el EURUSD llegar a la paridad? (Melchor Arme...
Blog Ethika Global: "¿Conseguirá el EURUSD llegar a la paridad? (Melchor Arme...
 
Question 3
Question 3Question 3
Question 3
 
Estado da arte em Codificação Criativa
Estado da arte em Codificação CriativaEstado da arte em Codificação Criativa
Estado da arte em Codificação Criativa
 
El negocio del SEO y cómo hacer que Google quiera tu web
El negocio del SEO y cómo hacer que Google quiera tu webEl negocio del SEO y cómo hacer que Google quiera tu web
El negocio del SEO y cómo hacer que Google quiera tu web
 
Pleura and pleural cavity copy
Pleura and pleural cavity   copyPleura and pleural cavity   copy
Pleura and pleural cavity copy
 
Towards Streamlined Technology-driven orchestration for Effective Teaching
Towards Streamlined Technology-driven orchestration for Effective TeachingTowards Streamlined Technology-driven orchestration for Effective Teaching
Towards Streamlined Technology-driven orchestration for Effective Teaching
 

Similar to Numerical Methods for Engineers and Scientists: An Introduction with Applications Using MATLAB

Module I CSAS_105152.pdf
Module I CSAS_105152.pdfModule I CSAS_105152.pdf
Module I CSAS_105152.pdfKovendan Akp
 
Chapter 15 - Methods and Applications of Integration
Chapter 15 - Methods and Applications of IntegrationChapter 15 - Methods and Applications of Integration
Chapter 15 - Methods and Applications of IntegrationMuhammad Bilal Khairuddin
 
Introductory maths analysis chapter 15 official
Introductory maths analysis   chapter 15 officialIntroductory maths analysis   chapter 15 official
Introductory maths analysis chapter 15 officialEvert Sandye Taasiringan
 
Chapter15 methodsandapplicationsofintegration-151007044206-lva1-app6891
Chapter15 methodsandapplicationsofintegration-151007044206-lva1-app6891Chapter15 methodsandapplicationsofintegration-151007044206-lva1-app6891
Chapter15 methodsandapplicationsofintegration-151007044206-lva1-app6891Cleophas Rwemera
 

Similar to Numerical Methods for Engineers and Scientists: An Introduction with Applications Using MATLAB (8)

Lecture#2,ch 02
Lecture#2,ch 02Lecture#2,ch 02
Lecture#2,ch 02
 
Module I CSAS_105152.pdf
Module I CSAS_105152.pdfModule I CSAS_105152.pdf
Module I CSAS_105152.pdf
 
REvit training
REvit trainingREvit training
REvit training
 
Chapter 15 - Methods and Applications of Integration
Chapter 15 - Methods and Applications of IntegrationChapter 15 - Methods and Applications of Integration
Chapter 15 - Methods and Applications of Integration
 
Introductory maths analysis chapter 15 official
Introductory maths analysis   chapter 15 officialIntroductory maths analysis   chapter 15 official
Introductory maths analysis chapter 15 official
 
Chapter15 methodsandapplicationsofintegration-151007044206-lva1-app6891
Chapter15 methodsandapplicationsofintegration-151007044206-lva1-app6891Chapter15 methodsandapplicationsofintegration-151007044206-lva1-app6891
Chapter15 methodsandapplicationsofintegration-151007044206-lva1-app6891
 
Lecture#4,ch 02
Lecture#4,ch 02Lecture#4,ch 02
Lecture#4,ch 02
 
refreshENM1500.pdf
refreshENM1500.pdfrefreshENM1500.pdf
refreshENM1500.pdf
 

Recently uploaded

Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 

Recently uploaded (20)

Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 

Numerical Methods for Engineers and Scientists: An Introduction with Applications Using MATLAB

  • 1. This document is intended for internal use only and shall not be distributed outside of GUtech in Oman Numerical Methods for Engineers and Scientists Lecturer: Assistant Prof. Dr. AYDIN AZIZI
  • 2. Slide 2 Copyright © 2014 John Wiley & Sons, Inc. All rights reserved. Third Edition Amos Gilat • Vish Subramaniam Numerical Methods for Engineers and Scientists
  • 3. Slide 3 Lecturer: Assistant Prof. Dr. Aydin Azizi Introduction to MATLAB Lecturer: Assistant Prof. Dr. Aydin Azizi
  • 4. Slide 4 Lecturer: Assistant Prof. Dr. Aydin Azizi Example of MATLAB Release 13 desktop Lecturer: Assistant Prof. Dr. Aydin Azizi
  • 5. Slide 5 Lecturer: Assistant Prof. Dr. Aydin Azizi Variables – Vectors and Matrices – • ALL variables are matrices Variables •They are case–sensitive i.e. x  X •Their names can contain up to 31 characters •Must start with a letter •Variables are stored in workspace e.g. 1 x 1 4 x 1 1 x 4 2 x 4       4239 6512 7123             3 9 2 3  4 Lecturer: Assistant Prof. Dr. Aydin Azizi
  • 6. Slide 6 Lecturer: Assistant Prof. Dr. Aydin Azizi How do we assign a value to a variable? >>> v1=3 v1 = 3 >>> i1=4 i1 = 4 >>> R=v1/i1 R = 0.7500 >>> >>> whos Name Size Bytes Class R 1x1 8 double array i1 1x1 8 double array v1 1x1 8 double array Grand total is 3 elements using 24 bytes >>> who Your variables are: R i1 v1 >>> Lecturer: Assistant Prof. Dr. Aydin Azizi
  • 7. Slide 7 Lecturer: Assistant Prof. Dr. Aydin Azizi How do we assign values to vectors? >>> A = [1 2 3 4 5] A = 1 2 3 4 5 >>> >>> B = [10;12;14;16;18] B = 10 12 14 16 18 >>> A row vector values are separated by spaces  54321A                   18 16 14 12 10 B A column vector values are separated by semi–colon (;) Lecturer: Assistant Prof. Dr. Aydin Azizi
  • 8. Slide 8 Lecturer: Assistant Prof. Dr. Aydin Azizi How do we assign values to vectors? • If we want to construct a vector of, say, 100 elements between 0 and 2 – linspace >>> c1 = linspace(0,(2*pi),100); >>> whos Name Size Bytes Class c1 1x100 800 double array Grand total is 100 elements using 800 bytes >>> Lecturer: Assistant Prof. Dr. Aydin Azizi
  • 9. Slide 9 Lecturer: Assistant Prof. Dr. Aydin Azizi How do we assign values to vectors? If we want to construct an array of, say, 100 elements between 0 and 2 – colon notation >>> c2 = (0:0.0201:2)*pi; >>> whos Name Size Bytes Class c1 1x100 800 double array c2 1x100 800 double array Grand total is 200 elements using 1600 bytes >>> Lecturer: Assistant Prof. Dr. Aydin Azizi
  • 10. Slide 10 Lecturer: Assistant Prof. Dr. Aydin Azizi How do we assign values to matrices ? Columns separated by space or a comma Rows separated by semi-colon >>> A=[1 2 3;4 5 6;7 8 9] A = 1 2 3 4 5 6 7 8 9 >>>           987 654 321 Lecturer: Assistant Prof. Dr. Aydin Azizi
  • 11. Slide 11 Lecturer: Assistant Prof. Dr. Aydin Azizi How do we access elements in a matrix or a vector? >>> A(2,3) ans = 6 >>> A(:,3) ans = 3 6 9 >>> A(1,:) ans = 1 2 3 >>> A(2,:) ans = 4 5 6 Lecturer: Assistant Prof. Dr. Aydin Azizi
  • 12. Slide 12 Lecturer: Assistant Prof. Dr. Aydin Azizi Some special variables pi () inf (e.g. 1/0) i, j ( )1 >>> 1/0 Warning: Divide by zero. ans = Inf >>> pi ans = 3.1416 >>> i ans = 0+ 1.0000i Lecturer: Assistant Prof. Dr. Aydin Azizi
  • 13. Slide 13 Lecturer: Assistant Prof. Dr. Aydin Azizi Arithmetic operations – Matrices Performing operations to every entry in a matrix Add and subtract>>> A=[1 2 3;4 5 6;7 8 9] A = 1 2 3 4 5 6 7 8 9 >>> >>> A+3 ans = 4 5 6 7 8 9 10 11 12 >>> A-2 ans = -1 0 1 2 3 4 5 6 7 Lecturer: Assistant Prof. Dr. Aydin Azizi
  • 14. Slide 14 Lecturer: Assistant Prof. Dr. Aydin Azizi Arithmetic operations – Matrices Performing operations to every entry in a matrix Multiply and divide>>> A=[1 2 3;4 5 6;7 8 9] A = 1 2 3 4 5 6 7 8 9 >>> >>> A*2 ans = 2 4 6 8 10 12 14 16 18 >>> A/3 ans = 0.3333 0.6667 1.0000 1.3333 1.6667 2.0000 2.3333 2.6667 3.0000 Lecturer: Assistant Prof. Dr. Aydin Azizi
  • 15. Slide 15 Lecturer: Assistant Prof. Dr. Aydin Azizi Arithmetic operations – Matrices Performing operations to every entry in a matrix Power >>> A=[1 2 3;4 5 6;7 8 9] A = 1 2 3 4 5 6 7 8 9 >>> A^2 = A * A To square every element in A, use the element–wise operator .^ >>> A.^2 ans = 1 4 9 16 25 36 49 64 81 >>> A^2 ans = 30 36 42 66 81 96 102 126 150 Lecturer: Assistant Prof. Dr. Aydin Azizi
  • 16. Slide 16 Lecturer: Assistant Prof. Dr. Aydin Azizi Performing operations between matrices >>> A=[1 2 3;4 5 6;7 8 9] A = 1 2 3 4 5 6 7 8 9 >>> B=[1 1 1;2 2 2;3 3 3] B = 1 1 1 2 2 2 3 3 3 A*B                     333 222 111 987 654 321 A.*B           3x93x83x7 2x62x52x4 1x31x21x1           272421 12108 321 = =           505050 323232 141414 Arithmetic operations – Matrices Lecturer: Assistant Prof. Dr. Aydin Azizi
  • 17. Slide 17 Lecturer: Assistant Prof. Dr. Aydin Azizi Roots- Logarithms
  • 18. Slide 18 Lecturer: Assistant Prof. Dr. Aydin Azizi Random Number
  • 19. Slide 19 Lecturer: Assistant Prof. Dr. Aydin Azizi Random Real Number
  • 20. Slide 20 Lecturer: Assistant Prof. Dr. Aydin Azizi Random Integer Number
  • 21. Slide 21 Lecturer: Assistant Prof. Dr. Aydin Azizi Practice
  • 22. Slide 22 Lecturer: Assistant Prof. Dr. Aydin Azizi Characters and Encoding
  • 23. Slide 23 Lecturer: Assistant Prof. Dr. Aydin Azizi Characters and Encoding
  • 24. Slide 24 Lecturer: Assistant Prof. Dr. Aydin Azizi Characters and Encoding
  • 25. Slide 25 Lecturer: Assistant Prof. Dr. Aydin Azizi Practice
  • 26. Slide 26 Lecturer: Assistant Prof. Dr. Aydin Azizi Relational Expressions
  • 27. Slide 27 Lecturer: Assistant Prof. Dr. Aydin Azizi Relational Expressions
  • 28. Slide 28 Lecturer: Assistant Prof. Dr. Aydin Azizi Relational Expressions
  • 29. Slide 29 Lecturer: Assistant Prof. Dr. Aydin Azizi Logical Operators
  • 30. Slide 30 Lecturer: Assistant Prof. Dr. Aydin Azizi Logical Operators
  • 31. Slide 31 Lecturer: Assistant Prof. Dr. Aydin Azizi Logical Operators
  • 32. Slide 32 Lecturer: Assistant Prof. Dr. Aydin Azizi Truth Table for Logical Operators
  • 33. Slide 33 Lecturer: Assistant Prof. Dr. Aydin Azizi Logical Error
  • 34. Slide 34 Lecturer: Assistant Prof. Dr. Aydin Azizi Logical Error
  • 35. Slide 35 Lecturer: Assistant Prof. Dr. Aydin Azizi Practice
  • 36. Slide 36 Lecturer: Assistant Prof. Dr. Aydin Azizi While Loop count = 0; number = 8; while number > 3 number = number - 2 count = count+1 end
  • 37. Slide 37 Lecturer: Assistant Prof. Dr. Aydin Azizi FOR Loop mat=rand(5,6) [r c] = size(mat) for i = 1:r for j = 1:c mat(i,j) = mat(i,j) * 2 end end
  • 38. Slide 38 Lecturer: Assistant Prof. Dr. Aydin Azizi IF Loop x=rand(10,1); v = [ ] for i = 1:length(x) if x(i) > 0 v = [v i] end end