SlideShare a Scribd company logo
1
MATLAB Programming
2
MATLAB
a flagship software which was originally developed as a
matrix library. A variety of numerical functions, symbolic
computations, and visualization tools have been added to the
matrix manipulations.
Demo programs:
http://web.mst.edu/~ercal/228/MATLAB/1-2/analpara.m
http://web.mst.edu/~ercal/228/MATLAB/1-2/analpara2.m
http://web.mst.edu/~ercal/228/MATLAB/1-2/analpara4.m
))](([)()( 11 iiiii tttv
m
c
gtvtv  
3
Sample Program
• g=9.8;
• cd=12.5;
• m = 68.1;
• dt = input('time increment (s):');
• tf = input('final time (s):');
• ti=0;
• vi=0;
• while (1)
• dvdt = g-(cd/m)*vi;
• vi = vi + dvdt*dt;
• ti = ti + dt;
• if ti >= tf, break, end
• end
• disp('velocity (m/s):')
• disp(vi)
t (sec.) V (m/s)
0 0
2 19.60
4 32.00
8 44.82
10 47.97
12 49.96
∞ 53.39
m=68.1 kg; c=12.5 kg/s; g=9.8 m/s
))](([)()( 11 iiiii tttv
m
c
gtvtv  
4
Built-in functions
sqrt(x)
exp(x)
abs(x)
log(x)
log10(x)
factorial(x)
TRIGONEMETRIC
sin(x)
sind(x)
cos(x)
cosd(x)
tan(x)
tand(x)
cot(x)
cotd(x)
Rounding functions
round(x)
fix(x) - round towards zero
ceil(x)
floor(x)
rem(x,y) – returns the remainder
after x is divided by y
(similar to % function in C)
Display formats
format short : 41.4286
format long:
41.42857142857143
format short e: 4.1429e+001
format long e:
4.142857142857143e+0001
format short g: 41.429
format long g:
41.4285714285714
format bank: 41.43
format compact: eliminates
empty lines
format loose: adds empty lines
5
Plot function
>> x=0:1:5
x =
0 1 2 3 4 5
>> y = sin(10*x) + cos(3*x)
y =
1.0000 -1.5340 1.8731 -1.8992 1.5890 -1.0221
>> plot(x,y)
>> xlabel('x in radians')
>> ylabel('y = sin(10*x) + cos(3*x)')
>>
>> z = zeros(1,6) % alternative way z=0*x
z =
0 0 0 0 0 0
>> plot(x,y, x,z)
>> xlabel('x in radians')
>> ylabel('y = sin(10*x) + cos(3*x)')
6
Roots of polynomials
>> r = [1, -2, 4]
r =
1 -2 4
>> poly(r)
ans =
1 -3 -6 8
>> p = poly(r)
p =
1 -3 -6 8
>> solve = roots(p)
solve =
4.0000
-2.0000
1.0000
System of equations
>> x=[-1, 5]
x =
-1 5
>> A = [2, 3; -1, 4]
A =
2 3
-1 4
>> b = A*x'
b =
13
21
>> solveX = inv(A)*b
solveX =
-1.0000
5.0000
**here Fundamental control structures in MATLAB
Managing Variables
clear – removes all variables from memory clear x y – removes only x and y from memory
who – displays a list of variables in the memory whos – displays a list of variables in the
memory along with their size and class
FOR-Loop sum = 0;
DOFOR i = start, step, final for i = 2:1:25
(Loop Body) sum = sum + A[i];
ENDDO end
• Spreadsheet that allows the user to enter and perform calculations on rows
and columns of data.
• When any value on the sheet is changed, entire calculation is updated,
therefore, spreadsheets are ideal for “what if?” sorts of analysis.
• Excel has some built in numerical capabilities including equation solving,
curve fitting and optimization.
• It has several visualization tools, such as graphs and three dimensional
plots.
• It also includes Visual Basic (VBA) as a macro language that can be used
to implement numerical calculations.
check out: http://www.anthony-vba.kefra.com/vba/vbabasic1.htm
EXCEL
Special Problem 2

More Related Content

What's hot

Simplifying development-short - Mirco Dotta (Typesafe)
Simplifying development-short - Mirco Dotta (Typesafe)Simplifying development-short - Mirco Dotta (Typesafe)
Simplifying development-short - Mirco Dotta (Typesafe)
Scala Italy
 
Basic of octave matlab programming language
Basic of octave matlab programming languageBasic of octave matlab programming language
Basic of octave matlab programming language
Aulia Khalqillah
 
Programming withmatlab
Programming withmatlabProgramming withmatlab
Programming withmatlabnehanairm
 
Seminar fp
Seminar fpSeminar fp
GNU octave
GNU octaveGNU octave
GNU octave
gauravmalav
 
Mbd2
Mbd2Mbd2
MATLAB for Technical Computing
MATLAB for Technical ComputingMATLAB for Technical Computing
MATLAB for Technical Computing
Naveed Rehman
 
Scilab presentation
Scilab presentation Scilab presentation
Scilab presentation
Nasir Ansari
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
Satish Gummadi
 
matlab
matlabmatlab
matlab
Farhan Ahmed
 
Matlab solved problems
Matlab solved problemsMatlab solved problems
Matlab solved problems
Make Mannan
 
Ss matlab solved
Ss matlab solvedSs matlab solved
Ss matlab solved
Vijendrasingh Rathor
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
Manchireddy Reddy
 
Matlab matrices and arrays
Matlab matrices and arraysMatlab matrices and arrays
Matlab matrices and arrays
Ameen San
 
Lecture 8-9 block-diagram_representation_of_control_systems
Lecture 8-9 block-diagram_representation_of_control_systemsLecture 8-9 block-diagram_representation_of_control_systems
Lecture 8-9 block-diagram_representation_of_control_systemsSaifullah Memon
 
2D Plot Matlab
2D Plot Matlab2D Plot Matlab
2D Plot Matlab
Jorge Jasso
 
Network security CS6
Network security   CS6Network security   CS6
Network security CS6
Infinity Tech Solutions
 

What's hot (20)

Simplifying development-short - Mirco Dotta (Typesafe)
Simplifying development-short - Mirco Dotta (Typesafe)Simplifying development-short - Mirco Dotta (Typesafe)
Simplifying development-short - Mirco Dotta (Typesafe)
 
Basic of octave matlab programming language
Basic of octave matlab programming languageBasic of octave matlab programming language
Basic of octave matlab programming language
 
Programming withmatlab
Programming withmatlabProgramming withmatlab
Programming withmatlab
 
Seminar fp
Seminar fpSeminar fp
Seminar fp
 
GNU octave
GNU octaveGNU octave
GNU octave
 
Mbd2
Mbd2Mbd2
Mbd2
 
MATLAB for Technical Computing
MATLAB for Technical ComputingMATLAB for Technical Computing
MATLAB for Technical Computing
 
Matlab1
Matlab1Matlab1
Matlab1
 
Scilab presentation
Scilab presentation Scilab presentation
Scilab presentation
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
matlab
matlabmatlab
matlab
 
Matlab solved problems
Matlab solved problemsMatlab solved problems
Matlab solved problems
 
Ss matlab solved
Ss matlab solvedSs matlab solved
Ss matlab solved
 
What is matlab
What is matlabWhat is matlab
What is matlab
 
Matlab lec1
Matlab lec1Matlab lec1
Matlab lec1
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
 
Matlab matrices and arrays
Matlab matrices and arraysMatlab matrices and arrays
Matlab matrices and arrays
 
Lecture 8-9 block-diagram_representation_of_control_systems
Lecture 8-9 block-diagram_representation_of_control_systemsLecture 8-9 block-diagram_representation_of_control_systems
Lecture 8-9 block-diagram_representation_of_control_systems
 
2D Plot Matlab
2D Plot Matlab2D Plot Matlab
2D Plot Matlab
 
Network security CS6
Network security   CS6Network security   CS6
Network security CS6
 

Similar to Applied numerical methods lec2

Mat lab workshop
Mat lab workshopMat lab workshop
Mat lab workshop
Vinay Kumar
 
Matlab-1.pptx
Matlab-1.pptxMatlab-1.pptx
Matlab-1.pptx
aboma2hawi
 
Matlab ppt
Matlab pptMatlab ppt
Matlab ppt
chestialtaff
 
Big datacourse
Big datacourseBig datacourse
Big datacourse
Massimiliano Ruocco
 
4413-lecture-09 Introduction Matlab lecture .ppt
4413-lecture-09 Introduction Matlab lecture .ppt4413-lecture-09 Introduction Matlab lecture .ppt
4413-lecture-09 Introduction Matlab lecture .ppt
aaaaboud1
 
Introduction to Matlab.pdf
Introduction to Matlab.pdfIntroduction to Matlab.pdf
Introduction to Matlab.pdf
ssuser43b38e
 
Programming with matlab session 1
Programming with matlab session 1Programming with matlab session 1
Programming with matlab session 1
Infinity Tech Solutions
 
Chapter 1.ppt
Chapter 1.pptChapter 1.ppt
Chapter 1.ppt
Indra Hermawan
 
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnNumerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
Arnaud Joly
 
MATLAB Programming
MATLAB Programming MATLAB Programming
MATLAB Programming
محمدعبد الحى
 
A practical work of matlab
A practical work of matlabA practical work of matlab
A practical work of matlab
SalanSD
 
22CS201 COA
22CS201 COA22CS201 COA
22CS201 COA
Kathirvel Ayyaswamy
 
Matlab intro
Matlab introMatlab intro
Matlab intro
Chaitanya Banoth
 
Matlab_Harshal.pptx
Matlab_Harshal.pptxMatlab_Harshal.pptx
Matlab_Harshal.pptx
HarshalGosavi8
 
R Programming Intro
R Programming IntroR Programming Intro
R Programming Intro
062MayankSinghal
 
Matlab basic and image
Matlab basic and imageMatlab basic and image
Matlab basic and image
Divyanshu Rasauria
 
Introduction of MatLab
Introduction of MatLab Introduction of MatLab
Introduction of MatLab
Imran Nawaz
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.ppt
kebeAman
 

Similar to Applied numerical methods lec2 (20)

Mat lab workshop
Mat lab workshopMat lab workshop
Mat lab workshop
 
Matlab-1.pptx
Matlab-1.pptxMatlab-1.pptx
Matlab-1.pptx
 
Matlab ppt
Matlab pptMatlab ppt
Matlab ppt
 
Learn Matlab
Learn MatlabLearn Matlab
Learn Matlab
 
Big datacourse
Big datacourseBig datacourse
Big datacourse
 
4413-lecture-09 Introduction Matlab lecture .ppt
4413-lecture-09 Introduction Matlab lecture .ppt4413-lecture-09 Introduction Matlab lecture .ppt
4413-lecture-09 Introduction Matlab lecture .ppt
 
Palm m3 chapter1b
Palm m3 chapter1bPalm m3 chapter1b
Palm m3 chapter1b
 
Introduction to Matlab.pdf
Introduction to Matlab.pdfIntroduction to Matlab.pdf
Introduction to Matlab.pdf
 
Programming with matlab session 1
Programming with matlab session 1Programming with matlab session 1
Programming with matlab session 1
 
Chapter 1.ppt
Chapter 1.pptChapter 1.ppt
Chapter 1.ppt
 
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnNumerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
 
MATLAB Programming
MATLAB Programming MATLAB Programming
MATLAB Programming
 
A practical work of matlab
A practical work of matlabA practical work of matlab
A practical work of matlab
 
22CS201 COA
22CS201 COA22CS201 COA
22CS201 COA
 
Matlab intro
Matlab introMatlab intro
Matlab intro
 
Matlab_Harshal.pptx
Matlab_Harshal.pptxMatlab_Harshal.pptx
Matlab_Harshal.pptx
 
R Programming Intro
R Programming IntroR Programming Intro
R Programming Intro
 
Matlab basic and image
Matlab basic and imageMatlab basic and image
Matlab basic and image
 
Introduction of MatLab
Introduction of MatLab Introduction of MatLab
Introduction of MatLab
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.ppt
 

More from Yasser Ahmed

Artificial reefs
Artificial reefsArtificial reefs
Artificial reefs
Yasser Ahmed
 
Novel approach of bidirectional diffuser-augmented channels system for enhanc...
Novel approach of bidirectional diffuser-augmented channels system for enhanc...Novel approach of bidirectional diffuser-augmented channels system for enhanc...
Novel approach of bidirectional diffuser-augmented channels system for enhanc...
Yasser Ahmed
 
Applied numerical methods lec14
Applied numerical methods lec14Applied numerical methods lec14
Applied numerical methods lec14
Yasser Ahmed
 
Applied numerical methods lec13
Applied numerical methods lec13Applied numerical methods lec13
Applied numerical methods lec13
Yasser Ahmed
 
Applied numerical methods lec12
Applied numerical methods lec12Applied numerical methods lec12
Applied numerical methods lec12
Yasser Ahmed
 
Applied numerical methods lec11
Applied numerical methods lec11Applied numerical methods lec11
Applied numerical methods lec11
Yasser Ahmed
 
Applied numerical methods lec10
Applied numerical methods lec10Applied numerical methods lec10
Applied numerical methods lec10
Yasser Ahmed
 
Applied numerical methods lec9
Applied numerical methods lec9Applied numerical methods lec9
Applied numerical methods lec9
Yasser Ahmed
 
Applied numerical methods lec8
Applied numerical methods lec8Applied numerical methods lec8
Applied numerical methods lec8
Yasser Ahmed
 
Applied numerical methods lec7
Applied numerical methods lec7Applied numerical methods lec7
Applied numerical methods lec7
Yasser Ahmed
 
Applied numerical methods lec6
Applied numerical methods lec6Applied numerical methods lec6
Applied numerical methods lec6
Yasser Ahmed
 
Applied numerical methods lec5
Applied numerical methods lec5Applied numerical methods lec5
Applied numerical methods lec5
Yasser Ahmed
 
Applied numerical methods lec4
Applied numerical methods lec4Applied numerical methods lec4
Applied numerical methods lec4
Yasser Ahmed
 
Applied numerical methods lec3
Applied numerical methods lec3Applied numerical methods lec3
Applied numerical methods lec3
Yasser Ahmed
 
Applied numerical methods lec1
Applied numerical methods lec1Applied numerical methods lec1
Applied numerical methods lec1
Yasser Ahmed
 

More from Yasser Ahmed (15)

Artificial reefs
Artificial reefsArtificial reefs
Artificial reefs
 
Novel approach of bidirectional diffuser-augmented channels system for enhanc...
Novel approach of bidirectional diffuser-augmented channels system for enhanc...Novel approach of bidirectional diffuser-augmented channels system for enhanc...
Novel approach of bidirectional diffuser-augmented channels system for enhanc...
 
Applied numerical methods lec14
Applied numerical methods lec14Applied numerical methods lec14
Applied numerical methods lec14
 
Applied numerical methods lec13
Applied numerical methods lec13Applied numerical methods lec13
Applied numerical methods lec13
 
Applied numerical methods lec12
Applied numerical methods lec12Applied numerical methods lec12
Applied numerical methods lec12
 
Applied numerical methods lec11
Applied numerical methods lec11Applied numerical methods lec11
Applied numerical methods lec11
 
Applied numerical methods lec10
Applied numerical methods lec10Applied numerical methods lec10
Applied numerical methods lec10
 
Applied numerical methods lec9
Applied numerical methods lec9Applied numerical methods lec9
Applied numerical methods lec9
 
Applied numerical methods lec8
Applied numerical methods lec8Applied numerical methods lec8
Applied numerical methods lec8
 
Applied numerical methods lec7
Applied numerical methods lec7Applied numerical methods lec7
Applied numerical methods lec7
 
Applied numerical methods lec6
Applied numerical methods lec6Applied numerical methods lec6
Applied numerical methods lec6
 
Applied numerical methods lec5
Applied numerical methods lec5Applied numerical methods lec5
Applied numerical methods lec5
 
Applied numerical methods lec4
Applied numerical methods lec4Applied numerical methods lec4
Applied numerical methods lec4
 
Applied numerical methods lec3
Applied numerical methods lec3Applied numerical methods lec3
Applied numerical methods lec3
 
Applied numerical methods lec1
Applied numerical methods lec1Applied numerical methods lec1
Applied numerical methods lec1
 

Recently uploaded

Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
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
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
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
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
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
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
abh.arya
 
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
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
Kamal Acharya
 

Recently uploaded (20)

Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
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
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
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
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
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
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
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
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 

Applied numerical methods lec2

  • 2. 2 MATLAB a flagship software which was originally developed as a matrix library. A variety of numerical functions, symbolic computations, and visualization tools have been added to the matrix manipulations. Demo programs: http://web.mst.edu/~ercal/228/MATLAB/1-2/analpara.m http://web.mst.edu/~ercal/228/MATLAB/1-2/analpara2.m http://web.mst.edu/~ercal/228/MATLAB/1-2/analpara4.m ))](([)()( 11 iiiii tttv m c gtvtv  
  • 3. 3 Sample Program • g=9.8; • cd=12.5; • m = 68.1; • dt = input('time increment (s):'); • tf = input('final time (s):'); • ti=0; • vi=0; • while (1) • dvdt = g-(cd/m)*vi; • vi = vi + dvdt*dt; • ti = ti + dt; • if ti >= tf, break, end • end • disp('velocity (m/s):') • disp(vi) t (sec.) V (m/s) 0 0 2 19.60 4 32.00 8 44.82 10 47.97 12 49.96 ∞ 53.39 m=68.1 kg; c=12.5 kg/s; g=9.8 m/s ))](([)()( 11 iiiii tttv m c gtvtv  
  • 4. 4 Built-in functions sqrt(x) exp(x) abs(x) log(x) log10(x) factorial(x) TRIGONEMETRIC sin(x) sind(x) cos(x) cosd(x) tan(x) tand(x) cot(x) cotd(x) Rounding functions round(x) fix(x) - round towards zero ceil(x) floor(x) rem(x,y) – returns the remainder after x is divided by y (similar to % function in C) Display formats format short : 41.4286 format long: 41.42857142857143 format short e: 4.1429e+001 format long e: 4.142857142857143e+0001 format short g: 41.429 format long g: 41.4285714285714 format bank: 41.43 format compact: eliminates empty lines format loose: adds empty lines
  • 5. 5 Plot function >> x=0:1:5 x = 0 1 2 3 4 5 >> y = sin(10*x) + cos(3*x) y = 1.0000 -1.5340 1.8731 -1.8992 1.5890 -1.0221 >> plot(x,y) >> xlabel('x in radians') >> ylabel('y = sin(10*x) + cos(3*x)') >> >> z = zeros(1,6) % alternative way z=0*x z = 0 0 0 0 0 0 >> plot(x,y, x,z) >> xlabel('x in radians') >> ylabel('y = sin(10*x) + cos(3*x)')
  • 6. 6 Roots of polynomials >> r = [1, -2, 4] r = 1 -2 4 >> poly(r) ans = 1 -3 -6 8 >> p = poly(r) p = 1 -3 -6 8 >> solve = roots(p) solve = 4.0000 -2.0000 1.0000 System of equations >> x=[-1, 5] x = -1 5 >> A = [2, 3; -1, 4] A = 2 3 -1 4 >> b = A*x' b = 13 21 >> solveX = inv(A)*b solveX = -1.0000 5.0000
  • 7. **here Fundamental control structures in MATLAB Managing Variables clear – removes all variables from memory clear x y – removes only x and y from memory who – displays a list of variables in the memory whos – displays a list of variables in the memory along with their size and class FOR-Loop sum = 0; DOFOR i = start, step, final for i = 2:1:25 (Loop Body) sum = sum + A[i]; ENDDO end
  • 8. • Spreadsheet that allows the user to enter and perform calculations on rows and columns of data. • When any value on the sheet is changed, entire calculation is updated, therefore, spreadsheets are ideal for “what if?” sorts of analysis. • Excel has some built in numerical capabilities including equation solving, curve fitting and optimization. • It has several visualization tools, such as graphs and three dimensional plots. • It also includes Visual Basic (VBA) as a macro language that can be used to implement numerical calculations. check out: http://www.anthony-vba.kefra.com/vba/vbabasic1.htm EXCEL
  • 9.