Chapter 3 -Built-in Matlab Functions
-
Upload
siva-gopal -
Category
Documents
-
view
62 -
download
5
Transcript of Chapter 3 -Built-in Matlab Functions
![Page 1: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/1.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Built-in Matlab Functions
Chapter 3 0 200 400 600 800 10000
20
40
60
80
100Test Scores
Student Number
Sco
re
0 20 40 60 80 1000
20
40
60
80
100
120Distribution of Test Scores
Score
# of
stu
dent
s
0 200 400 600 800 10000
20
40
60
80
100
Student Number
Sco
re
0 20 40 60 80 1000
20
40
60
80
100
120
Score
# of
stu
dent
s
Average = 50
Average = 50
Average = 50
Average = 50
![Page 2: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/2.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
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
![Page 3: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/3.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Matlab uses function names consistent
with most major programming languages
For example• sqrt• sin• cos• log
![Page 4: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/4.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Function Input can be either scalars or matrices
![Page 5: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/5.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Function Input can be either scalars or matrices
![Page 6: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/6.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Using Predefined Functions
• Functions consist of• Name• Input argument(s)• Output
sqrt (x)= resultIn MATLAB sqrt(4) ans = 2
![Page 7: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/7.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Some functions require multiple inputs
• Remainder function returns the remainder in a division problem
• For example the remainder of 10/3, is 1
![Page 8: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/8.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Some functions return multiple results
• size function determines the number of rows and columns
![Page 9: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/9.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
You can assign names to the output
![Page 10: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/10.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Nesting Functions
![Page 11: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/11.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
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
![Page 12: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/12.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r From the Command Window
![Page 13: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/13.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
From the Help Menu
![Page 14: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/14.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
![Page 15: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/15.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Elementary Math Functions
• abs(x) absolute value• sign(x) plus or minus• exp(x) ex
• log(x) natural log• log10(x) log base 10
![Page 16: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/16.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Rounding Functions
• round(x)• fix(x)• floor(x)• ceil(x)
![Page 17: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/17.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
![Page 18: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/18.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
![Page 19: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/19.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
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)
![Page 20: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/20.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
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
![Page 21: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/21.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Data Analysis
• max(x)• min(x)• mean(x)• median(x)• sum(x)• prod(x)• sort(x)
![Page 22: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/22.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
When x is a matrix, the max is found for each column
![Page 23: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/23.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r max value
element number where the max value occurs
![Page 24: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/24.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Vector of row numbers
Vector of maximums
![Page 25: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/25.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Determining Matrix Size
• size(x) number of rows and columns
• length(x) biggest dimension
![Page 26: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/26.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
![Page 27: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/27.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Variance and Standard Deviation
• std(x)• var(x)
11
2
2
N
xN
kk
2
![Page 28: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/28.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Standard Deviation
![Page 29: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/29.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
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
![Page 30: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/30.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
![Page 31: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/31.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
![Page 32: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/32.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
![Page 33: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/33.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Gaussian Random numbers
• randn(n)• Also called a normal distribution• Generates numbers with a mean
of 0 and a standard deviation of 1
![Page 34: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/34.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
![Page 35: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/35.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
![Page 36: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/36.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
![Page 37: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/37.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
To generate random numbers between other
bounds…
arabx a and b are the upper and lower boundsr is the array of random numbers
![Page 38: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/38.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
0 200 400 600 800 10000
20
40
60
80
100Test Scores
Student Number
Sco
re
0 20 40 60 80 1000
20
40
60
80
100
120Distribution of Test Scores
Score
# of
stu
dent
s
0 200 400 600 800 10000
20
40
60
80
100
Student Number
Sco
re
0 20 40 60 80 1000
20
40
60
80
100
120
Score
# of
stu
dent
s
Average = 50
Average = 50
Average = 50
Average = 50
![Page 39: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/39.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
More about Manipulating Matrices
• M(:)• Converts a two dimensional matrix
to a single column
![Page 40: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/40.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
![Page 41: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/41.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
![Page 42: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/42.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
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
![Page 43: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/43.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Computational Limits
• Matlab’s computational range on most computers is:• 10-308
• 10308
• When you divide by 0, the computer returns Inf
![Page 44: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/44.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Check the limits on your computer with these commands
• realmax• realmin• intmax• intmin
![Page 45: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/45.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
![Page 46: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/46.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
When using very large or very small numbers the result may depend on
the order of operation
![Page 47: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/47.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
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.
![Page 48: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/48.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Summary
• MATLAB contains a wide array of predefined functions• Elementary Math Functions• Trigonometric Functions• Data Analysis Functions• Random Numbers• Complex Numbers
![Page 49: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/49.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Summary
• The colon operator allows you to manipulate matrices
![Page 50: Chapter 3 -Built-in Matlab Functions](https://reader031.fdocuments.in/reader031/viewer/2022021506/5888f33a1a28ab87728b6bbd/html5/thumbnails/50.jpg)
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
Rat
e of
tem
pera
ture
cha
nge,
deg
rees
/hou
r
Summary
• Computational Limits• Special Values and Functions