SlideShare a Scribd company logo
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 manual
shahid naseem
 
Pmi servizio uc
Pmi servizio   ucPmi servizio   uc
Pmi servizio uc
Stefano Ligabue
 
додаток 5. універсали (2)
додаток 5. універсали (2)додаток 5. універсали (2)
додаток 5. універсали (2)
solom_nmc
 
Cordless
CordlessCordless
Conceptos basicos de probabilidad
Conceptos basicos de probabilidadConceptos basicos de probabilidad
Conceptos basicos de probabilidad
Jennifer Esquer
 
Amazing likeness
Amazing likenessAmazing likeness
Amazing likeness
Maya
 
Programa curricular-educacion-inicial
Programa curricular-educacion-inicialPrograma curricular-educacion-inicial
Programa curricular-educacion-inicial
Irene Villanueva
 
Edición de videos
Edición de videosEdición de videos
Edición de videos
angief31
 
Presentación biología 1
Presentación biología 1Presentación biología 1
Presentación biología 1
Eliana 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ónfinal
Sergio26Duran
 
4 matriz 7º a
4 matriz 7º a4 matriz 7º a
4 matriz 7º a
Marquês de Pombal
 
Ρομαντισμός
ΡομαντισμόςΡομαντισμός
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
 
Question 3
Question 3Question 3
Question 3
te05051789
 
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
UTFPR
 
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
Congreso Turismo Rural
 
Pleura and pleural cavity copy
Pleura and pleural cavity   copyPleura and pleural cavity   copy
Pleura and pleural cavity copy
Jeevan 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 Teaching
Lighton 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

Lecture#2,ch 02
Lecture#2,ch 02Lecture#2,ch 02
Lecture#2,ch 02
Aydin Azizi
 
Module I CSAS_105152.pdf
Module I CSAS_105152.pdfModule I CSAS_105152.pdf
Module I CSAS_105152.pdf
Kovendan Akp
 
REvit training
REvit trainingREvit training
REvit training
srinivasanvenkat10
 
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
Muhammad Bilal Khairuddin
 
Introductory maths analysis chapter 15 official
Introductory maths analysis   chapter 15 officialIntroductory maths analysis   chapter 15 official
Introductory maths analysis chapter 15 official
Evert Sandye Taasiringan
 
Chapter15 methodsandapplicationsofintegration-151007044206-lva1-app6891
Chapter15 methodsandapplicationsofintegration-151007044206-lva1-app6891Chapter15 methodsandapplicationsofintegration-151007044206-lva1-app6891
Chapter15 methodsandapplicationsofintegration-151007044206-lva1-app6891
Cleophas Rwemera
 
refreshENM1500.pdf
refreshENM1500.pdfrefreshENM1500.pdf
refreshENM1500.pdf
TheSilverLining
 

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

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
 
refreshENM1500.pdf
refreshENM1500.pdfrefreshENM1500.pdf
refreshENM1500.pdf
 

Recently uploaded

Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
JamalHussainArman
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball playEric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
enizeyimana36
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
NazakatAliKhoso2
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
zubairahmad848137
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 

Recently uploaded (20)

Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball playEric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 

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