Professional Documents
Culture Documents
cos
2
-----------------------
1
7
---
5
12
------
tan
64 tan
14 cos
2
-------------------
3 80 sin
0.9
3
--------------------
55 cos
11 sin
-----------------
2x
4
6x
3
14.8x
2
9.1
e
2x
14 x
2
x
------------------------------
t
2
t
3
( ) ln
75
2t
------
0.8t 3 ( ) cos
x
2
y
2
x
2
y
2
----- xy x y
x y
x 2y
--------------
2
x
y
--
a 13 b 4.2 c 4b ( ) a d
abc
a b c
---------------------
a
b
c d
------------
d
c
---
a
b
---
a b
2
( ) c d ( )
a
2
b
2
d c ( )
--------------------- b a c d ( ) ln
a
b
P 2
1
2
---
a
2
b
2
( )
a 9
b 3
b 2a P 20
4x sin 4 x x cos sin 8 x sin
3
x cos 2x cos
1 x tan
2
1 x tan
2
----------------------
x
9
---
8. (a)
>> x = 8.3; y = 2.4;
>> x^2 + y^2 - (x^2 / y^2)
ans =
62.6899
8. (b)
>> x = 8.3; y = 2.4;
>> sqrt(x*y) - sqrt(x + y) + ((x - y)/(x - 2*y))^2 - sqrt(x/y)
ans =
2.1741
Example
Engineering MATLAB, MEEG221
Week 1: Starting with MATLAB
Four circles are placed as shown in the figure. At each point where two
circles are in contact they are tangent to each other. Determine the
distance between the centers C2 and C4.
The radii of the circles are:
R1 = 16mm, R2 = 6.5mm, R3 = 12mm, and
R4 = 9.5mm.
24 Chapter 1: Starting with MATLAB
1.9 EXAMPLES OF MATLAB APPLICATIONS
Sample Problem 1-1: Trigonometric identity
A trigonometric identity is given by:
Verify that the identity is correct by calculating each side of the equation, substi-
tuting .
Solution
The problem is solved by typing the following commands in the Command Win-
dow.
Sample Problem 1-2: Geometry and trigonometry
Four circles are placed as shown in the figure.
At each point where two circles are in contact
they are tangent to each other. Determine the
distance between the centers C
2
and C
4
.
The radii of the circles are:
mm, mm, mm, and
mm.
Solution
The lines that connect the centers of the cir-
cles create four triangles. In two of the trian-
gles, C
1
C
2
C
3
and C
1
C
3
C
4
, the lengths of all
the sides are known. This information is used to
calculate the angles
1
and
2
in these triangles by
using the law of cosines. For example,
1
is cal-
culated from:
>> x=pi/5;
>> LHS=cos(x/2)^2
LHS =
0.9045
>> RHS=(tan(x)+sin(x))/(2*tan(x))
RHS =
0.9045
x
2
--- cos
2
x tan x sin
2 x tan
---------------------------
x
5
---
Define x.
Calculate the left-hand side.
Calculate the right-hand side.
R
1
16 R
2
6.5 R
3
12
R
4
9.5
24 Chapter 1: Starting with MATLAB
1.9 EXAMPLES OF MATLAB APPLICATIONS
Sample Problem 1-1: Trigonometric identity
A trigonometric identity is given by:
Verify that the identity is correct by calculating each side of the equation, substi-
tuting .
Solution
The problem is solved by typing the following commands in the Command Win-
dow.
Sample Problem 1-2: Geometry and trigonometry
Four circles are placed as shown in the figure.
At each point where two circles are in contact
they are tangent to each other. Determine the
distance between the centers C
2
and C
4
.
The radii of the circles are:
mm, mm, mm, and
mm.
Solution
The lines that connect the centers of the cir-
cles create four triangles. In two of the trian-
gles, C
1
C
2
C
3
and C
1
C
3
C
4
, the lengths of all
the sides are known. This information is used to
calculate the angles
1
and
2
in these triangles by
using the law of cosines. For example,
1
is cal-
culated from:
>> x=pi/5;
>> LHS=cos(x/2)^2
LHS =
0.9045
>> RHS=(tan(x)+sin(x))/(2*tan(x))
RHS =
0.9045
x
2
--- cos
2
x tan x sin
2 x tan
---------------------------
x
5
---
Define x.
Calculate the left-hand side.
Calculate the right-hand side.
R
1
16 R
2
6.5 R
3
12
R
4
9.5
(C
2
C
3
)
2
= (C
1
C
2
)
2
+ (C
1
C
3
)
2
! 2(C
1
C
2
)(C
1
C
3
) cos("
1
)
(C
3
C
4
)
2
= (C
1
C
3
)
2
+ (C
1
C
4
)
2
! 2(C
1
C
3
)(C
1
C
4
) cos("
2
)
(C
2
C
4
)
2
= (C
1
C
2
)
2
+ (C
1
C
4
)
2
! 2(C
1
C
2
)(C
1
C
4
) cos("
3
)
!
3
= !
1
+!
2
Examples
Engineering MATLAB, MEEG221
Week 1: Starting with MATLAB
1.9 Examples of MATLAB Applications 25
Next, the length of the side C
2
C
4
is calculated by considering the triangle
C
1
C
2
C
4
. This is done, again, by using the law of cosines (the lengths C
1
C
2
and
C
1
C
4
are known and the angle
3
is the sum of the angles
1
and
2
).
The problem is solved by writing the following program in a script file:
When the script file is executed, the following (the value of the variable C2C4) is
displayed in the Command Window:
Sample Problem 1-3: Heat transfer
An object with an initial temperature of that is placed at time t = 0 inside a
chamber that has a constant temperature of will experience a temperature
change according to the equation
where T is the temperature of the object at time t, and k is a constant. A soda can at
a temperature of F (after being left in the car) is placed inside a refrigerator
where the temperature is F. Determine, to the nearest degree, the temperature
of the can after three hours. Assume k = 0.45. First define all of the variables and
then calculate the temperature using one MATLAB command.
Solution
The problem is solved by typing the following commands in the Command Win-
dow.
% Solution of Sample Problem 1-2
R1=16; R2=6.5; R3=12; R4=9.5;
C1C2=R1+R2; C1C3=R1+R3; C1C4=R1+R4;
C2C3=R2+R3; C3C4=R3+R4;
Gama1=acos((C1C2^2+C1C3^2-C2C3^2)/(2*C1C2*C1C3));
Gama2=acos((C1C3^2+C1C4^2-C3C4^2)/(2*C1C3*C1C4));
Gama3=Gama1+Gama2;
C2C4=sqrt(C1C2^2+C1C4^2-2*C1C2*C1C4*cos(Gama3))
C2C4 =
33.5051
C
2
C
3
( )
2
C
1
C
2
( )
2
C
1
C
3
( )
2
2 C
1
C
2
( ) C
1
C
3
( )
1
cos
Define the Rs.
Calculate the
lengths of the sides.
Calculate
1
,
2
, and
3
.
Calculate the length of
side C
2
C
4
.
T
0
T
s
T T
s
T
0
T
s
( )e
kt
120
38
1.9 Examples of MATLAB Applications 25
Next, the length of the side C
2
C
4
is calculated by considering the triangle
C
1
C
2
C
4
. This is done, again, by using the law of cosines (the lengths C
1
C
2
and
C
1
C
4
are known and the angle
3
is the sum of the angles
1
and
2
).
The problem is solved by writing the following program in a script file:
When the script file is executed, the following (the value of the variable C2C4) is
displayed in the Command Window:
Sample Problem 1-3: Heat transfer
An object with an initial temperature of that is placed at time t = 0 inside a
chamber that has a constant temperature of will experience a temperature
change according to the equation
where T is the temperature of the object at time t, and k is a constant. A soda can at
a temperature of F (after being left in the car) is placed inside a refrigerator
where the temperature is F. Determine, to the nearest degree, the temperature
of the can after three hours. Assume k = 0.45. First define all of the variables and
then calculate the temperature using one MATLAB command.
Solution
The problem is solved by typing the following commands in the Command Win-
dow.
% Solution of Sample Problem 1-2
R1=16; R2=6.5; R3=12; R4=9.5;
C1C2=R1+R2; C1C3=R1+R3; C1C4=R1+R4;
C2C3=R2+R3; C3C4=R3+R4;
Gama1=acos((C1C2^2+C1C3^2-C2C3^2)/(2*C1C2*C1C3));
Gama2=acos((C1C3^2+C1C4^2-C3C4^2)/(2*C1C3*C1C4));
Gama3=Gama1+Gama2;
C2C4=sqrt(C1C2^2+C1C4^2-2*C1C2*C1C4*cos(Gama3))
C2C4 =
33.5051
C
2
C
3
( )
2
C
1
C
2
( )
2
C
1
C
3
( )
2
2 C
1
C
2
( ) C
1
C
3
( )
1
cos
Define the Rs.
Calculate the
lengths of the sides.
Calculate
1
,
2
, and
3
.
Calculate the length of
side C
2
C
4
.
T
0
T
s
T T
s
T
0
T
s
( )e
kt
120
38
Thanks!
Question?
Engineering MATLAB, MEEG221
Week 1: Starting with MATLAB