SlideShare a Scribd company logo
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Built-in Matlab
Functions
Chapter 3 0 200 400 600 800 1000
0
20
40
60
80
100
Test Scores
Student Number
Score
0 20 40 60 80 100
0
20
40
60
80
100
120
Distribution of Test Scores
Score
#ofstudents
0 200 400 600 800 1000
0
20
40
60
80
100
Student Number
Score
0 20 40 60 80 100
0
20
40
60
80
100
120
Score
#ofstudents
Average = 50
Average = 50
Average = 50
Average = 50
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
In this chapter we’ll cover
• Using Built in Functions
• Using the Help Feature
• Elementary Math Functions
• Trigonometric Functions
• Data Analysis Functions
• Random Number Functions
• Complex Number Functions
• Computational Limits
• Special Values and Miscellaneous Functions
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Matlab uses function names consistent
with most major programming languages
For example
• sqrt
• sin
• cos
• log
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Function Input can be either
scalars or matrices
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Function Input can be either
scalars or matrices
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Using Predefined
Functions
• Functions consist of
• Name
• Input argument(s)
• Output
sqrt (x)= result
In MATLAB
sqrt(4)
ans = 2
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Some functions require
multiple inputs
• Remainder function returns the
remainder in a division problem
• For example the remainder of
10/3, is 1
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Some functions return
multiple results
• size function determines the
number of rows and columns
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
You can assign names to
the output
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Nesting Functions
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
There are functions for almost
anything you want to do
• Use the help feature to find out
what they are and how to use
them
• From the command window
• From the help selection on the
menu bar
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
From the Command Window
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
From the Help Menu
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Elementary Math
Functions
• abs(x) absolute value
• sign(x) plus or minus
• exp(x) ex
• log(x) natural log
• log10(x) log base 10
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Rounding Functions
• round(x)
• fix(x)
• floor(x)
• ceil(x)
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Discrete Mathmatics
• factor(x)
• gcd(x,y) greatest common denominator
• lcm(x) lowest common multiple
• rats(x) represent x as a fraction
• factorial(x)
• primes(x)
• isprime(x)
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Trigonometric Functions
• sin(x) sine
• cos(x) cosine
• tan(x) tangent
• asin(x) inverse sine
• sinh(x) hyperbolic sine
• asinh(x) inverse hyperbolic sine
• sind(x) sine with degree input
• asind(x) inverse sin with degree
output
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Data Analysis
• max(x)
• min(x)
• mean(x)
• median(x)
• sum(x)
• prod(x)
• sort(x)
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
When x is a matrix,
the max is found for
each column
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
max value
element number
where the max
value occurs
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Vector of row numbers
Vector of maximums
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Determining Matrix Size
• size(x) number of rows and
columns
• length(x) biggest dimension
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Variance and Standard
Deviation
• std(x)
• var(x)
( )
1
1
2
2
−
−
=
∑=
N
x
N
k
k µ
σ
2
σ
σ
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Standard Deviation
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Random Numbers
• rand(x)
• Returns an x by x matrix of random
numbers between 0 and 1
• rand(n,m)
• Returns an n by m matrix of random
numbers
• These random numbers are
evenly distributed
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Gaussian Random
numbers
• randn(n)
• Also called a normal distribution
• Generates numbers with a mean
of 0 and a standard deviation of 1
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
To generate random
numbers between other
bounds…
( ) arabx +⋅−=
a and b are the upper and lower
bounds
r is the array of random numbers
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
0 200 400 600 800 1000
0
20
40
60
80
100
Test Scores
Student Number
Score
0 20 40 60 80 100
0
20
40
60
80
100
120
Distribution of Test Scores
Score
#ofstudents
0 200 400 600 800 1000
0
20
40
60
80
100
Student Number
Score
0 20 40 60 80 100
0
20
40
60
80
100
120
Score
#ofstudents
Average = 50
Average = 50
Average = 50
Average = 50
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
More about Manipulating
Matrices
• M(:)
• Converts a two dimensional matrix
to a single column
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Complex Numbers
• complex(x,y)
• real(A) used if A is a
complex number
• imag(A)
• isreal(A)
• conj(A)
• abs(A)
• angle(A)
real
imaginary
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Computational Limits
• Matlab’s computational range on
most computers is:
• 10-308
• 10308
• When you divide by 0, the
computer returns Inf
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Check the limits on your
computer with these commands
• realmax
• realmin
• intmax
• intmin
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
When using very large or very small
numbers the result may depend on
the order of operation
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Special Values and
Functions
• pi
• i,j
• Inf
• NaN
• clock
• date
• eps
• ans
Hint: The function i is the
most common of these
functions to be
unintentionally renamed
by Matlab users.
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Summary
• MATLAB contains a wide array of
predefined functions
• Elementary Math Functions
• Trigonometric Functions
• Data Analysis Functions
• Random Numbers
• Complex Numbers
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Summary
• The colon operator allows you to
manipulate matrices
Matlab for Engineers
100 200 300 400 500
100
200
300
400
500
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-5
-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
Rate of Change
time, hour
Rateoftemperaturechange,degrees/hour
Summary
• Computational Limits
• Special Values and Functions

More Related Content

What's hot

Matlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processingMatlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processing
Dr. Manjunatha. P
 
K-map method
K-map methodK-map method
K-map method
Harekushna Patel
 
Presentation on Numerical Integration
Presentation on Numerical IntegrationPresentation on Numerical Integration
Presentation on Numerical Integration
Tausif Shahanshah
 
Matlab Functions
Matlab FunctionsMatlab Functions
Matlab Functions
Umer Azeem
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabSantosh V
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
Tarun Gehlot
 
Matlab Introduction
Matlab IntroductionMatlab Introduction
Matlab Introduction
ideas2ignite
 
Matlab-fundamentals of matlab-1
Matlab-fundamentals of matlab-1Matlab-fundamentals of matlab-1
Matlab-fundamentals of matlab-1
Narendra Kumar Jangid
 
Brief Introduction to Matlab
Brief  Introduction to MatlabBrief  Introduction to Matlab
Brief Introduction to Matlab
Tariq kanher
 
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
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
BilawalBaloch1
 
Matlab solved problems
Matlab solved problemsMatlab solved problems
Matlab solved problems
Make Mannan
 
Matlab (Presentation on MATLAB)
Matlab (Presentation on MATLAB)Matlab (Presentation on MATLAB)
Matlab (Presentation on MATLAB)
Chetan Allapur
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
Dnyanesh Patil
 
Sampling
SamplingSampling
Sampling
srkrishna341
 
Matlab ploting
Matlab plotingMatlab ploting
Matlab ploting
Ameen San
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
Ravikiran A
 
Matlab
MatlabMatlab
Matlab
sandhya jois
 

What's hot (20)

Matlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processingMatlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processing
 
K-map method
K-map methodK-map method
K-map method
 
Presentation on Numerical Integration
Presentation on Numerical IntegrationPresentation on Numerical Integration
Presentation on Numerical Integration
 
Matlab Functions
Matlab FunctionsMatlab Functions
Matlab Functions
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Matlab ppt
Matlab pptMatlab ppt
Matlab ppt
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Matlab Introduction
Matlab IntroductionMatlab Introduction
Matlab Introduction
 
Matlab-fundamentals of matlab-1
Matlab-fundamentals of matlab-1Matlab-fundamentals of matlab-1
Matlab-fundamentals of matlab-1
 
Laplace transform
Laplace transformLaplace transform
Laplace transform
 
Brief Introduction to Matlab
Brief  Introduction to MatlabBrief  Introduction to Matlab
Brief Introduction to Matlab
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginners
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Matlab solved problems
Matlab solved problemsMatlab solved problems
Matlab solved problems
 
Matlab (Presentation on MATLAB)
Matlab (Presentation on MATLAB)Matlab (Presentation on MATLAB)
Matlab (Presentation on MATLAB)
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Sampling
SamplingSampling
Sampling
 
Matlab ploting
Matlab plotingMatlab ploting
Matlab ploting
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
Matlab
MatlabMatlab
Matlab
 

Viewers also liked

Introduction to Matlab
Introduction to MatlabIntroduction to Matlab
Introduction to Matlab
Amr Rashed
 
Chapter 5 - Plotting
Chapter 5 - PlottingChapter 5 - Plotting
Chapter 5 - PlottingSiva Gopal
 
Spark of Innovation white paper
Spark of Innovation white paperSpark of Innovation white paper
Spark of Innovation white paperKyle Weckerly
 
Libro de MATLAB
Libro de MATLABLibro de MATLAB
Libro de MATLAB
guestecaca7
 
Keyboard
KeyboardKeyboard
Keyboard
BESOR ACADEMY
 
How to work on Matlab.......
How to work on Matlab.......How to work on Matlab.......
How to work on Matlab.......biinoida
 
Matlab Presentation
Matlab PresentationMatlab Presentation
Matlab Presentation
Mohamed El Rayany
 
Advanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & ScientistsAdvanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & Scientists
Ray Phan
 
Introduction to strain gages
Introduction to strain gagesIntroduction to strain gages
MATLAB Programs For Beginners. | Abhi Sharma
MATLAB Programs For Beginners. | Abhi SharmaMATLAB Programs For Beginners. | Abhi Sharma
MATLAB Programs For Beginners. | Abhi Sharma
Abee Sharma
 
Assembly of screw jack
Assembly of screw jackAssembly of screw jack
FDM Numerical solution of Laplace Equation using MATLAB
FDM Numerical solution of Laplace Equation using MATLABFDM Numerical solution of Laplace Equation using MATLAB
FDM Numerical solution of Laplace Equation using MATLAB
Aya Zaki
 

Viewers also liked (13)

Introduction to Matlab
Introduction to MatlabIntroduction to Matlab
Introduction to Matlab
 
Chapter 5 - Plotting
Chapter 5 - PlottingChapter 5 - Plotting
Chapter 5 - Plotting
 
Spark of Innovation white paper
Spark of Innovation white paperSpark of Innovation white paper
Spark of Innovation white paper
 
Libro de MATLAB
Libro de MATLABLibro de MATLAB
Libro de MATLAB
 
Keyboard
KeyboardKeyboard
Keyboard
 
How to work on Matlab.......
How to work on Matlab.......How to work on Matlab.......
How to work on Matlab.......
 
Matlab Presentation
Matlab PresentationMatlab Presentation
Matlab Presentation
 
Advanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & ScientistsAdvanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & Scientists
 
Introduction to strain gages
Introduction to strain gagesIntroduction to strain gages
Introduction to strain gages
 
MATLAB Programs For Beginners. | Abhi Sharma
MATLAB Programs For Beginners. | Abhi SharmaMATLAB Programs For Beginners. | Abhi Sharma
MATLAB Programs For Beginners. | Abhi Sharma
 
Assembly of screw jack
Assembly of screw jackAssembly of screw jack
Assembly of screw jack
 
FDM Numerical solution of Laplace Equation using MATLAB
FDM Numerical solution of Laplace Equation using MATLABFDM Numerical solution of Laplace Equation using MATLAB
FDM Numerical solution of Laplace Equation using MATLAB
 
Riveted joints
Riveted jointsRiveted joints
Riveted joints
 

Similar to Chapter 3 -Built-in Matlab Functions

Chapter 4 - Manipulating Matlab Matrices
Chapter 4 - Manipulating Matlab MatricesChapter 4 - Manipulating Matlab Matrices
Chapter 4 - Manipulating Matlab MatricesSiva Gopal
 
Chapter 1 -About Matlab
Chapter 1 -About MatlabChapter 1 -About Matlab
Chapter 1 -About MatlabSiva Gopal
 
Chapter 2 - Matlab Environment
Chapter 2 - Matlab EnvironmentChapter 2 - Matlab Environment
Chapter 2 - Matlab EnvironmentSiva Gopal
 
Mat lab workshop
Mat lab workshopMat lab workshop
Mat lab workshop
Vinay Kumar
 
7 channel Interleaved Boost Converter
7 channel Interleaved Boost Converter7 channel Interleaved Boost Converter
7 channel Interleaved Boost Converter
ZunAib Ali
 
Time series representations for better data mining
Time series representations for better data miningTime series representations for better data mining
Time series representations for better data mining
Peter Laurinec
 
ScalaMeter 2012
ScalaMeter 2012ScalaMeter 2012
ScalaMeter 2012
Aleksandar Prokopec
 
Autonomic Resource Provisioning for Cloud-Based Software
Autonomic Resource Provisioning for Cloud-Based SoftwareAutonomic Resource Provisioning for Cloud-Based Software
Autonomic Resource Provisioning for Cloud-Based Software
Pooyan Jamshidi
 
ScalaMeter 2014
ScalaMeter 2014ScalaMeter 2014
ScalaMeter 2014
Aleksandar Prokopec
 
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
MLconf
 
Mat lab
Mat labMat lab
Histograms in 12c era
Histograms in 12c eraHistograms in 12c era
Histograms in 12c era
Mauro Pagano
 
Fuzzy Control meets Software Engineering
Fuzzy Control meets Software EngineeringFuzzy Control meets Software Engineering
Fuzzy Control meets Software Engineering
Pooyan Jamshidi
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
Ghassan Al-Yafie
 
Monitoring Complex Systems: Keeping Your Head on Straight in a Hard World
Monitoring Complex Systems: Keeping Your Head on Straight in a Hard WorldMonitoring Complex Systems: Keeping Your Head on Straight in a Hard World
Monitoring Complex Systems: Keeping Your Head on Straight in a Hard World
Brian Troutwine
 
Manufacturing System Introduction
Manufacturing System IntroductionManufacturing System Introduction
Manufacturing System Introduction
Muhammad Muddassir
 
Generating Automated and Online Test Oracles for Simulink Models with Continu...
Generating Automated and Online Test Oracles for Simulink Models with Continu...Generating Automated and Online Test Oracles for Simulink Models with Continu...
Generating Automated and Online Test Oracles for Simulink Models with Continu...
Lionel Briand
 
A Framework for Robust Control of Uncertainty in Self-Adaptive Software Conn...
 A Framework for Robust Control of Uncertainty in Self-Adaptive Software Conn... A Framework for Robust Control of Uncertainty in Self-Adaptive Software Conn...
A Framework for Robust Control of Uncertainty in Self-Adaptive Software Conn...
Pooyan Jamshidi
 
Marios Michailidis & Mathias Muller, H2O.ai - Time Series with H2O Driverless...
Marios Michailidis & Mathias Muller, H2O.ai - Time Series with H2O Driverless...Marios Michailidis & Mathias Muller, H2O.ai - Time Series with H2O Driverless...
Marios Michailidis & Mathias Muller, H2O.ai - Time Series with H2O Driverless...
Sri Ambati
 

Similar to Chapter 3 -Built-in Matlab Functions (20)

Chapter 4 - Manipulating Matlab Matrices
Chapter 4 - Manipulating Matlab MatricesChapter 4 - Manipulating Matlab Matrices
Chapter 4 - Manipulating Matlab Matrices
 
Chapter 1 -About Matlab
Chapter 1 -About MatlabChapter 1 -About Matlab
Chapter 1 -About Matlab
 
Chapter 2 - Matlab Environment
Chapter 2 - Matlab EnvironmentChapter 2 - Matlab Environment
Chapter 2 - Matlab Environment
 
Mat lab workshop
Mat lab workshopMat lab workshop
Mat lab workshop
 
7 channel Interleaved Boost Converter
7 channel Interleaved Boost Converter7 channel Interleaved Boost Converter
7 channel Interleaved Boost Converter
 
Time series representations for better data mining
Time series representations for better data miningTime series representations for better data mining
Time series representations for better data mining
 
ScalaMeter 2012
ScalaMeter 2012ScalaMeter 2012
ScalaMeter 2012
 
Autonomic Resource Provisioning for Cloud-Based Software
Autonomic Resource Provisioning for Cloud-Based SoftwareAutonomic Resource Provisioning for Cloud-Based Software
Autonomic Resource Provisioning for Cloud-Based Software
 
ScalaMeter 2014
ScalaMeter 2014ScalaMeter 2014
ScalaMeter 2014
 
ARIMA.pptx
ARIMA.pptxARIMA.pptx
ARIMA.pptx
 
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
 
Mat lab
Mat labMat lab
Mat lab
 
Histograms in 12c era
Histograms in 12c eraHistograms in 12c era
Histograms in 12c era
 
Fuzzy Control meets Software Engineering
Fuzzy Control meets Software EngineeringFuzzy Control meets Software Engineering
Fuzzy Control meets Software Engineering
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
 
Monitoring Complex Systems: Keeping Your Head on Straight in a Hard World
Monitoring Complex Systems: Keeping Your Head on Straight in a Hard WorldMonitoring Complex Systems: Keeping Your Head on Straight in a Hard World
Monitoring Complex Systems: Keeping Your Head on Straight in a Hard World
 
Manufacturing System Introduction
Manufacturing System IntroductionManufacturing System Introduction
Manufacturing System Introduction
 
Generating Automated and Online Test Oracles for Simulink Models with Continu...
Generating Automated and Online Test Oracles for Simulink Models with Continu...Generating Automated and Online Test Oracles for Simulink Models with Continu...
Generating Automated and Online Test Oracles for Simulink Models with Continu...
 
A Framework for Robust Control of Uncertainty in Self-Adaptive Software Conn...
 A Framework for Robust Control of Uncertainty in Self-Adaptive Software Conn... A Framework for Robust Control of Uncertainty in Self-Adaptive Software Conn...
A Framework for Robust Control of Uncertainty in Self-Adaptive Software Conn...
 
Marios Michailidis & Mathias Muller, H2O.ai - Time Series with H2O Driverless...
Marios Michailidis & Mathias Muller, H2O.ai - Time Series with H2O Driverless...Marios Michailidis & Mathias Muller, H2O.ai - Time Series with H2O Driverless...
Marios Michailidis & Mathias Muller, H2O.ai - Time Series with H2O Driverless...
 

Chapter 3 -Built-in Matlab Functions

  • 1. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Built-in Matlab Functions Chapter 3 0 200 400 600 800 1000 0 20 40 60 80 100 Test Scores Student Number Score 0 20 40 60 80 100 0 20 40 60 80 100 120 Distribution of Test Scores Score #ofstudents 0 200 400 600 800 1000 0 20 40 60 80 100 Student Number Score 0 20 40 60 80 100 0 20 40 60 80 100 120 Score #ofstudents Average = 50 Average = 50 Average = 50 Average = 50
  • 2. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour In this chapter we’ll cover • Using Built in Functions • Using the Help Feature • Elementary Math Functions • Trigonometric Functions • Data Analysis Functions • Random Number Functions • Complex Number Functions • Computational Limits • Special Values and Miscellaneous Functions
  • 3. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Matlab uses function names consistent with most major programming languages For example • sqrt • sin • cos • log
  • 4. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Function Input can be either scalars or matrices
  • 5. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Function Input can be either scalars or matrices
  • 6. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Using Predefined Functions • Functions consist of • Name • Input argument(s) • Output sqrt (x)= result In MATLAB sqrt(4) ans = 2
  • 7. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Some functions require multiple inputs • Remainder function returns the remainder in a division problem • For example the remainder of 10/3, is 1
  • 8. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Some functions return multiple results • size function determines the number of rows and columns
  • 9. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour You can assign names to the output
  • 10. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Nesting Functions
  • 11. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour There are functions for almost anything you want to do • Use the help feature to find out what they are and how to use them • From the command window • From the help selection on the menu bar
  • 12. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour From the Command Window
  • 13. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour From the Help Menu
  • 14. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour
  • 15. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Elementary Math Functions • abs(x) absolute value • sign(x) plus or minus • exp(x) ex • log(x) natural log • log10(x) log base 10
  • 16. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Rounding Functions • round(x) • fix(x) • floor(x) • ceil(x)
  • 17. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour
  • 18. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour
  • 19. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Discrete Mathmatics • factor(x) • gcd(x,y) greatest common denominator • lcm(x) lowest common multiple • rats(x) represent x as a fraction • factorial(x) • primes(x) • isprime(x)
  • 20. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Trigonometric Functions • sin(x) sine • cos(x) cosine • tan(x) tangent • asin(x) inverse sine • sinh(x) hyperbolic sine • asinh(x) inverse hyperbolic sine • sind(x) sine with degree input • asind(x) inverse sin with degree output
  • 21. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Data Analysis • max(x) • min(x) • mean(x) • median(x) • sum(x) • prod(x) • sort(x)
  • 22. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour When x is a matrix, the max is found for each column
  • 23. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour max value element number where the max value occurs
  • 24. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Vector of row numbers Vector of maximums
  • 25. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Determining Matrix Size • size(x) number of rows and columns • length(x) biggest dimension
  • 26. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour
  • 27. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Variance and Standard Deviation • std(x) • var(x) ( ) 1 1 2 2 − − = ∑= N x N k k µ σ 2 σ σ
  • 28. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Standard Deviation
  • 29. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Random Numbers • rand(x) • Returns an x by x matrix of random numbers between 0 and 1 • rand(n,m) • Returns an n by m matrix of random numbers • These random numbers are evenly distributed
  • 30. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour
  • 31. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour
  • 32. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour
  • 33. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Gaussian Random numbers • randn(n) • Also called a normal distribution • Generates numbers with a mean of 0 and a standard deviation of 1
  • 34. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour
  • 35. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour
  • 36. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour
  • 37. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour To generate random numbers between other bounds… ( ) arabx +⋅−= a and b are the upper and lower bounds r is the array of random numbers
  • 38. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour 0 200 400 600 800 1000 0 20 40 60 80 100 Test Scores Student Number Score 0 20 40 60 80 100 0 20 40 60 80 100 120 Distribution of Test Scores Score #ofstudents 0 200 400 600 800 1000 0 20 40 60 80 100 Student Number Score 0 20 40 60 80 100 0 20 40 60 80 100 120 Score #ofstudents Average = 50 Average = 50 Average = 50 Average = 50
  • 39. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour More about Manipulating Matrices • M(:) • Converts a two dimensional matrix to a single column
  • 40. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour
  • 41. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour
  • 42. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Complex Numbers • complex(x,y) • real(A) used if A is a complex number • imag(A) • isreal(A) • conj(A) • abs(A) • angle(A) real imaginary
  • 43. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Computational Limits • Matlab’s computational range on most computers is: • 10-308 • 10308 • When you divide by 0, the computer returns Inf
  • 44. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Check the limits on your computer with these commands • realmax • realmin • intmax • intmin
  • 45. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour
  • 46. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour When using very large or very small numbers the result may depend on the order of operation
  • 47. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Special Values and Functions • pi • i,j • Inf • NaN • clock • date • eps • ans Hint: The function i is the most common of these functions to be unintentionally renamed by Matlab users.
  • 48. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Summary • MATLAB contains a wide array of predefined functions • Elementary Math Functions • Trigonometric Functions • Data Analysis Functions • Random Numbers • Complex Numbers
  • 49. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Summary • The colon operator allows you to manipulate matrices
  • 50. Matlab for Engineers 100 200 300 400 500 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 Rate of Change time, hour Rateoftemperaturechange,degrees/hour Summary • Computational Limits • Special Values and Functions

Editor's Notes

  1. Welcome to Matlab for Engineers – Chapter Three. In this chapter we’ll explore a number of the functions built into Matlab.
  2. In particular we’ll cover using builit in functions and the help feature. We’ll look at…. and the computational limits that control our use of these functions.
  3. Sin and cos are also standard function names, as is l-o-g for natural logarithm.
  4. Let’s take a look at the square root function.
  5. Let’s take a look at the square root function.
  6. All functions consist of three basic parts
  7. Variance and standard deviation are statistical measures of variation in data. The definition of variance
  8. This is a representation of data that varies in what is called a normal distribution. It’s the bell curve, that’s often used by teachers to analyze student scores.
  9. Matlab can generate random numbers that are distrubuted using two schemes . The first is an even distribution and uses the rand function