Matlab CH 1 Solution
Matlab CH 1 Solution
Solved Problems
1. Calculate:
(a) (b)
Solution
2. Calculate:
(a) (b)
Solution
3. Calculate:
(a) (b)
Solution
4. Calculate:
(a) (b)
Solution
5. Calculate:
(a) (b)
Solution
Solution
>> z=4.5;
>> % Part (a)
>> 0.4*z^4+3.1*z^2-162.3*z-80.7
ans =
-584.2500
>> % Part (b)
>> (z^3-23)/(z^2+17.5)^(1/3)
ans =
20.3080
(a) (b)
Solution
>> t=3.2;
>> % Part (a)
>> exp(2*t)/2-3.81*t^3
ans =
176.0764
4 Chapter 1: Solved Problems
(a) (b)
Solution
(a) (b)
Solution
Solution
>> x=pi/10;
>> % Part (a)
>> Left=cos(x)^2-sin(x)^2
Left =
0.8090
>> Right=1-2*sin(x)^2
Right =
0.8090
>> % Part (b)
>> Left=tan(x)/(sin(x)-2*tan(x))
Left =
-0.9533
>> Right=1/(cos(x)-2)
Right =
-0.9533
(a) (b)
For each part, verify that the identity is correct by calculating the values of
the left and right sides of the equation, substituting .
Solution
>> x=20;
>> % Part (a)
>> Left=(sind(x)+cosd(x))^2
Left =
1.6428
>> Right=1+2*sind(x)*cosd(x)
Right =
1.6428
>> % Part (b)
>> Left=(1-2*cosd(x)-3*cosd(x)^2)/sind(x)^2
Left =
6 Chapter 1: Solved Problems
-30.1634
>> Right=(1-3*cosd(x))/(1-cosd(x))
Right =
-30.1634
12. Define two variables: alpha = π/8, and beta = π/6. Using these variables, show
that the following trigonometric identity is correct by calculating the values
of the left and right sides of the equation.
Solution
Solution
Solution
>> a=sqrt(23^2+43^2)
a =
48.7647
>> b=sqrt(16^2+23^2)
b =
28.0179
>> c=sqrt(43^2+16^2)
c =
45.8803
>> % Part (a)
>> AngleABC=acosd((a^2+c^2-b^2)/(2*a*c))
AngleABC =
34.2665
>> % Part (b)
>> p=(a+b+c)/2;
>> A=sqrt(p*(p-a)*(p-b)*(p-c))
A =
629.8589
8 Chapter 1: Solved Problems
h
Determine LABC if a=8 in. and h=13 in. C x
A a a
Solution
Solution
Script File:
Command Window:
>> HW_1_16
Gam =
Chapter 1: Solved Problems 9
94.4117
Bet =
49.6798
Alp =
35.9085
SumAng =
180
h
Solution di
Law of Tangents:
Solution
Script file:
% HW 1_18 6ed
clear,clc
a=27; b=43; c=57;
disp('Part (a)')
10 Chapter 1: Solved Problems
Al=acosd((-a^2+b^2+c^2)/(2*b*c))
Bet=acosd((-b^2+a^2+c^2)/(2*a*c))
Gum=acosd((-c^2+a^2+b^2)/(2*a*b))
Tot=Al+Bet+Gum
disp('Part (b)')
LHS=(b-c)/(b+c)
RHS=tand((Bet-Gum)/2)/tand((Bet+Gum)/2)
Command Window:
Part (a)
Al =
26.9669
Bet =
46.2365
Gum =
106.7966
Tot =
180
Part (b)
LHS =
-0.1400
RHS =
-0.1400
where .
Solution
Script File:
A=72; B=43;
G=180-A-B;
Chapter 1: Solved Problems 11
% Part (a)
a=114/(1+sind(B)/sind(A)+sind(G)/sind(A))
b=a*sind(B)/sind(A)
c=a*sind(G)/sind(A)
% Part (b)
s=(a+b+c)/2;
r=sqrt((s-a)*(s-b)*(s-c)/s)
Command Window:
a =
42.6959
b =
30.6171
c =
40.6870
r =
10.3925
Solution
Script file:
clear, clc
12 Chapter 1: Solved Problems
Command Window:
DIS =
5.6655
>>
x
a
Solution
Command Window:
22. 4217 eggs have to be packed in boxes that can hold 36 eggs each. By typing
one line (command) in the Command Window, calculate how many eggs
will remain unpacked if every box that is used has to be full. (Hint: use
MATLAB built-in function fix.)
Solution
Command Window:
>> 4217-fix(4217/36)*36
ans =
5
23. 777 people have to be transported using buses that have 46 seats and vans
that have 12 seats. Calculate how many buses are needed if all the buses have
to be full, and how many seats will remain empty in the vans if enough vans
are used to transport all the people that did not fit into the buses. (Hint: use
MATLAB built-in functions fix. and ceil)
Solution
Command Window:
>> nBuses=fix(777/46)
nBuses =
16
>> nPeoLeft=777-nBuses*46
nPeoLeft =
41
>> nVans=ceil(nPeoLeft/12)
nVans =
4
>> nSeatEmp=nVans*12-nPeoLeft
nSeatEmp =
7
14 Chapter 1: Solved Problems
24. Change the display to format long g. Assign the number 7E8/13 to a
variable, and then use the variable in a mathematical expression to calculate
the following by typing one command:
(a) Round the number to the nearest tenth.
(b) Round the number to the nearest million.
Solution
Command Window:
R4 R3
where and . Calculate
the Vab if volts, ohms,
ohms, ohms, and ohms.
Solution
Command Window:
format short
>> V=15; R1=119.8; R2=120.5; R3=121.2; R4=119.3;
>> c=R2/R1; d=R3/R4;
>> Vab=V*(c-d)/((c+1)*(d+1))
Vab =
-0.0374
Chapter 1: Solved Problems 15
Solution
Command Window:
27. The Monthly payment M of a mortgage P for n years with a fixed annual
interest rate r can be calculated by the formula:
Solution
Command Window:
(a) Determine how many 6-letter passwords can be formed from the 26 let-
ters in the English alphabet if a letter can only be used once.
(b) How many passwords can be formed if the digits 0, 1, 2, ....., 9 can be
used in addition to the letters.
Solution
Command Window:
In the Powerball Lottery game the player chooses 5 numbers from 1 through
59, and then the Powerball number from 1 through 35.
Determine how many combinations are possible by calculating .
(Use the built-in function factorial.)
Solution
Command Window:
>> C5_59=factorial(59)/(factorial(5)*factorial(59-5));
>> C1_35=factorial(35)/(factorial(1)*factorial(35-1));
>> Combination=C5_59*C1_35
Combination =
1.752235100000000e+08
Chapter 1: Solved Problems 17
Solution
Command Window:
Command Window:
Vout =
29.4545
>>
18 Chapter 1: Solved Problems
32. Radioactive decay of carbon-14 is used for estimating the age of organic
material. The decay is modeled with the exponential function ,
where t is time, is the amount of material at , is the amount
of material at time t, and k is a constant. Carbon-14 has a half-life of
approximately 5,730 years. A sample taken from the ancient footprints of
Acahualinca in Nicaragua shows that 77.45% of the initial ( ) carbon-
14 is present. Determine the estimated age of the footprint. Solve the prob-
lem by writing a program in a script file. The program first determines the
constant k, then calculates t for , and finally rounds the
answer to the nearest year.
Solution
Command Window:
>> k=log(0.5)/5730
k =
-0.00012097
>> Age=round(log(.7745)/k)
Age =
2112
>>
33. The greatest common divisor is the largest positive integer that divides the
numbers without a remainder. For example, the GCD of 8 and 12 is 4. Use
the MATLAB Help Window to find a MATLAB built-in function that
determines the greatest common divisor of two numbers. Then use the func-
tion to show that the greatest common divisor of:
(a) 91 and 147 is 7.
(b) 555 and 962 is 37.
Solution
Command Window:
>> gcd(555,962)
ans =
37
Solution
Command Window:
where c is the speed of light (about m/s) and v is the speed the
observer moves toward the light source. Calculate the speed the observer
has to move in order to see a red light as green. Green wavelength is 530nm
20 Chapter 1: Solved Problems
Solution
Command Window:
>> c=300E6;
>> LR=630; LG=530;
>> r=530/630;
>> v=c*((1-r^2)/(r^2+1))
v =
5.1343e+07
>>
36. Newton’s law of cooling gives the temperature T(t) of an object at time t in
terms of T0, its temperature at , and Ts, the temperature of the sur-
roundings.
A police officer arrives at a crime scene in a hotel room at 9:18 PM, where
he finds a dead body. He immediately measures the body’s temperature and
find it to be 79.5ºF. Exactly one hour later he measures the temperature
again, and find it to be 78.0ºF. Determine the time of death, assuming that
victim body temperature was normal (98.6ºF) prior to death, and that the
room temperature was constant at 69ºF.
Solution
Script File:
clear, clc
% Determining k:
Ts=69; T0=79.5; T60=78;
ta=60;
k=log((T0-Ts)/(T60-Ts))/ta;
% Determine min before 9:18 PM
T0=98.6; T9_18=79.5;
tb=round(log((T0-Ts)/(T9_18-Ts))/k);
Time=9*60+18-tb;
Hr=fix(Time/60)
Min=Time-Hr*60
Chapter 1: Solved Problems 21
Command Window:
Hr =
2
Min =
35
37. The velocity v and the falling distance d as a function of time of a skydiver
that experience the air resistance can be approximated by:
and
Solution
Command Window:
38. Use the Help Window to find a display format that displays the output as a
ratio of integers. For example, the number 3.125 will be displayed as 25/8.
Change the display to this format and execute the following operations:
(a) (b)
Solution
Command Window:
>> 5/8+16/6
ans =
79/24
>> 1/3-11/13+2.7^2
ans =
1247/184
Use the formula for calculating 19!. Compare the result with the true value
obtained with MATLAB’s built-in function factorial by calculating the
error (Error=(TrueVal-ApproxVal)/TrueVal).
Solution
Command Window:
>> n=19;
>> nApp=sqrt((2*n+1/3)*pi)*n^n*exp(-n)
nApp =
1.216428232016491e+17
>> nTru=factorial(n)
nTru =
1.216451004088320e+17
>> Error=(nTru-nApp)/nTru
Error =
1.872008963197555e-05
where m1 and m2 are the masses of the bodies, r is the distance between the
bodies, and N-m2/kg2 is the universal gravitational constant.
Determine how many times the attraction force between the sun and the
earth is larger than the attraction force between the earth and the moon.
The distance between the sun and earth is m, the distance
between the moon and earth is m, kg,
Chapter 1: Solved Problems 23
Solution
Script File:
Command Window:
Ratio =
179
24 Chapter 1: Solved Problems