Krista Donaldson, Krista Donaldson
Chapter 1
An Overview of MATLAB - all with Video Answers
Educators
Chapter Questions
Make sure you know how to start and quit a MATLAB session. Use MATLAB to make the following calculations, using the values: $x=10$, $y=3$. Check the results using a calculator.
a. $u=x+y$
b. $v=x y$
c. $w=x / y$
d. $z=\sin x$
e. $r=8 \sin y$
f. $s=5 \sin (2 y)$
Check back soon!
Suppose that $x=2$ and $y=5$. Use MATLAB to compute the following.
a. $\frac{y x^3}{x-y}$
b. $\frac{3 x}{2 y}$
c. $\frac{3}{2} x y$
d. $\frac{x^5}{x^5-1}$
Check back soon!
Suppose that $x=3$ and $y=4$. Use MATLAB to compute the following, and check the results with a calculator.
a. $\left(1-\frac{1}{x^5}\right)^{-1}$
b. $3 \pi x^2$
c. $\frac{3 y}{4 x-8}$
d. $\frac{4(y-5)}{3 x-6}$
Check back soon!
Evaluate the following expressions in MATLAB for the given value of $x$. Check your answers by hand.
a. $y=6 x^3+\frac{4}{x}, \quad x=2$
b. $y=\frac{x}{4} 3, \quad x=8$
c. $y=\frac{(4 x)^2}{25}, \quad x=10$
d. $y=2 \frac{\sin x}{5}, \quad x=2$
e. $y=7\left(x^{1 / 3}\right)+4 x^{0.58}, x=20$
Teresa Fuston
Numerade Educator
Assuming that the variables $a, b, c, d$, and $f$ are scalars, write MATLAB statements to compute and display the following expressions. Test your statements for the values $a=1.12, b=2.34, c=0.72, d=0.81$, $f=19.83$.
$$
\begin{aligned}
& x=1+\frac{a}{b}+\frac{c}{f^2} \quad s=\frac{b-a}{d-c} \\
& r=\frac{1}{\frac{1}{a}+\frac{1}{b}+\frac{1}{c}+\frac{1}{d}} \quad y=a b \frac{1}{c} \frac{f^2}{2}
\end{aligned}
$$
Check back soon!
Use MATLAB to calculate
a. $\frac{3}{4}(6)\left(7^2\right)+\frac{4^5}{7^3-145}$
b. $\frac{48.2(55)-9^3}{53+14^2}$
c. $\frac{27^2}{4}+\frac{319^{4 / 5}}{5}+60(14)^{-3}$
Check your answers with a calculator.
Teresa Fuston
Numerade Educator
The volume of a sphere is given by $V=4 \pi r^3 / 3$, where $r$ is the radius. Use MATLAB to compute the radius of a sphere having a volume 30 percent greater than that of a sphere of radius 5 ft .
Aditya Balasubramanian
Numerade Educator
${ }^{\text {" }}$ Suppose that $x=-7-5 i$ and $y=4+3 i$. Use MATLAB to compute
a. $x+y$
b. $x y$
c. $x / y$
Sydney Trombly
Numerade Educator
Use MATLAB to compute the following. Check your answers by hand.
a. $(3+6 i)(-7-9 i)$
b. $\frac{5+4 i}{5-4 i}$
c. $\frac{3}{2} i$
d. $\frac{3}{2 i}$
Rakesh Kumar Sharma
Numerade Educator
Evaluate the following expressions in MATLAB, for the values $x=5+8 i$. $y=-6+7 i$. Check your answers by hand.
a. $u=x+y$
b. $v=x y$
c. $w=x / y$
d. $z=e^x$
e. $r=\sqrt{y}$
f. $s=x y^2$
Check back soon!
Engineers often need to estimate the pressure exerted by a gas in a container. The ideal gas law provides one way of making the estimate. The law is
$$ P=\frac{n R T}{V} $$ More accurate estimates can be made with the van der Waals equation: $$ P=\frac{n R T}{V-n b}-\frac{a n^2}{V^2} $$ where the term $n b$ is a correction for the volume of the molecules, and the term $a n^2 / V^2$ is a correction for molecular attractions. The values of $a$ and $b$ depend on the type of gas. The gas constant is $R$, the absolute temperature is $T$, the gas volume is $V$, and the number of gas molecules is indicated by $n$. If $n=1 \mathrm{~mol}$ of an ideal gas were confined to a volume of $V=22.41 \mathrm{~L}$ at $0^{\circ} \mathrm{C}(273.2 \mathrm{~K})$, it would exert a pressure of 1 atmosphere. In these units, $R=0.08206$.
For chlorine $\left(\mathrm{Cl}_2\right), a=6.49$ and $b=0.0562$. Compare the pressure estimates given by the ideal gas law and the van der Waals equation for 1 mol of $\mathrm{Cl}_2$ in 22.41 L at 273.2 K . What is the main cause of the difference in the two pressure estimates: the molecular volume or the molecular attractions?
Linda Winkler
Numerade Educator
The ideal gas law relates the pressure $P$, volume $V$, absolute temperature $T$, and amount of gas $n$. The law is
$$ P=\frac{n R T}{V} $$ where $R$ is the gas constant. An engineer must design a large natural gas storage tank to be expandable to maintain the pressure constant at 2.2 atmospheres. In December when the temperature is $4 \mathrm{~F}\left(-15^{\circ} \mathrm{C}\right)$, the volume of gas in the tank is $28.500 \mathrm{ft}^3$. What will the volume of the same quantity of gas be in July when the temperature is $88^{\circ} \mathrm{F}\left(31^{\circ} \mathrm{C}\right)$ ?
Aadit Sharma
Numerade Educator
Suppose $x$ takes on the values $x=1,1.2,1.4, \ldots .5$. Use MATLAB to compute the array $y$ that results from the function $y=7 \sin (4 x)$. Use MATLAB to determine how many elements are in the array $y$, and the value of the third element in the array $y$.
Check back soon!
Use MATLAB to determine how many elements are in the array $[\sin (-p 1 / 2): 0.05: \cos (0)]$. Use MATLAB to determine the 10th element.
Linh Vu
Numerade Educator
Use MATLAB to calculate
a. $e^{(-2.1)^2}+3.47 \log (14)+\sqrt[4]{287}$
b. $(3.4)^7 \log (14)+\sqrt[4]{287}$
c. $\cos ^2\left(\frac{4.12 \pi}{6}\right)$
d. $\cos \left(\frac{4.12 \pi}{6}\right)^2$
Check your answers with a calculator.
Suzanne W.
Numerade Educator
Use MATLAB to calculate
a. $6 \pi \tan ^{-1}(12.5)+4$
b. $5 \tan \left[3 \sin ^{-1}(13 / 5)\right]$
c. $5 \ln (7)$
d. $5 \log (7)$
Check your answers with a calculator.
Julian Wong
Numerade Educator
The Richter scale is a measure of the intensity of an earthquake. The energy $E$ (in joules) released by the quake is related to the magnitude $M$ on the Richter scale as follows. $$ E=10^{4.4} 10^{1.5 M} $$
How much more energy is released by a magnitude 7.3 quake than a 5.5 quake?
Carson Merrill
Numerade Educator
Use MATLAB to find the roots of $13 x^3+182 x^2-184 x+2503=0$.
Teresa Fuston
Numerade Educator
Use MATLAB to find the roots of the polynomial $36 x^3+12 x^2-5 x+10$.
Vishal Parmar
Numerade Educator
Determine which search path MATLAB uses on your computer. If you use a lab computer as well as a home computer, compare the two search paths. Where will MATLAB look for a user-created M-file on each computer?
Check back soon!
Use MATLAB to plot the function $T=6 \ln t-7 e^{0.2 t}$ over the interval $1 \leq t \leq 3$. Put a title on the plot and properly label the axes. The variable $T$ represents temperature in degrees Celsius; the variable $t$ represents time in minutes.
Chengyu Li
Numerade Educator
Use MATLAB to plot the functions $u=2 \log _{10}(60 x+1)$ and $v=3 \cos (6 x)$ over the interval $0 \leq x \leq 2$. Properly label the plot and each curve. The variables $u$ and $v$ represent speed in miles per hour; the variable $x$ represents distance in miles.
Carson Merrill
Numerade Educator
The Fourier series is a series representation of a periodic function in terms of sines and cosines. The Fourier series representation of the function
$$ f(x)=\left\{\begin{array}{rr} 1 & 0<x<\pi \\ -1 & -\pi<x<0 \end{array}\right. $$ is $$ \frac{4}{\pi}\left(\frac{\sin x}{1}+\frac{\sin 3 x}{3}+\frac{\sin 5 x}{5}+\frac{\sin 7 x}{7}+\cdots\right) $$
Plot on the same graph the function $f(x)$ and its series representation using the four terms shown.
Raj Bala
Numerade Educator
A cycloid is the curve described by a point $P$ on the circumference of a circular wheel of radius, $r$ rolling along the $x$ axis. The curve is described in parametric form by the equations $$ \begin{aligned} & x=r(\phi-\sin \phi) \\ & y=r(1-\cos \phi) \end{aligned} $$
Use these equations to plot the cycloid for $r=10$ inches and $0 \leq \phi \leq 4 \pi$.
Patrick Delos Reyes
Numerade Educator
Use MATLAB to solve the following set of equations. $$ \begin{aligned} 7 x+14 y-6 z & =95 \\ 12 x-5 y+9 z & =-50 \\ -5 x+7 y+15 z & =145 \end{aligned} $$
James Kiss
Numerade Educator
It is known that the function $y=a x^3+b x^2+c x+d$ passes through the following $(x, y)$ points: $(-1,8),(0,4),(1,10)$, and $(2,68)$. Use the MATLAB left division operator / to compute the coefficients $a, b, c$, and $d$ by writing and solving four linear equations in terms of the four unknowns $a, b, c$, and $d$.
Anthony Ramos
Numerade Educator
Create, save, and run a script file that solves the following set of equations for given values of $a, b$, and $c$. Check your file for the case $a=95$, $b=-50$, and $c=145$. $$ \begin{array}{r} 7 x+14 y-6 z=a \\ 12 x-5 y+9 z=b \\ -5 x+7 y+15 z=c \end{array} $$
Nyah Kshatriya
Numerade Educator
A fence around a field is shaped as shown in Figure P28. It consists of a rectangle of length $L$ and width $W$, and a right triangle that is symmetrical about the central horizontal axis of the rectangle. Suppose the width $W$ is known (in meters), and the enclosed area $A$ is known (in square meters). Write a MATLAB script file in terms of the given variables $W$ and $A$ to determine the length $L$ required so that the enclosed area is $A$. Also determine the total length of fence required. Test your script for the values $W=6 \mathrm{~m}$ and $A=80 \mathrm{~m}^2$.
Blank Blank
Numerade Educator
. The four-sided figure shown in Figure P29 consists of two triangles having a common side $a$. The law of cosines for the top triangle states that
$$ a^2=b_1^2+c_1^2-2 b_1 c_1 \cos A_1 $$ and a similar equation can be written for the bottom triangle. Develop a procedure for computing the length of side $c_2$ if you are given the lengths of sides $b_1, b_2$, and $c_1$, and the angles $A_1$ and $A_2$ in degrees. Write a script file to implement this procedure. Test your script using the following values: $b_1=180 \mathrm{~m}, b_2=165 \mathrm{~m}, c_1=115 \mathrm{~m}, A_1=120$ and $A_2=100$.
Joseph Liao
Numerade Educator
A fenced enclosure consists of a rectangle of length $L$ and width $2 R$, and a semicircle of radius $R$, as shown in Figure P30. The enclosure is to be built to have an area $A$ of $1600 \mathrm{ft}^2$. The cost of the fence is $\$ 40$ per foot for the curved portion, and $\$ 30$ per foot for the straight sides. Use a plot to determine with a resolution of 0.01 ft the values of $R$ and $L$ required to minimize the total cost of the fence. Also compute the minimum cost, and use a plot of the cost versus $R$ to analyze the sensitivity of the cost to a $\pm 20$ percent change in $R$ from its optimum value.
Carson Merrill
Numerade Educator
Use the MATLAB help facilities to find information about the following topics and symbols: plot, label, cos, cosine, :, and *,
Check back soon!
Use the MATLAB help facilities to determine what happens if you use the sqrt function with a negative argument.
AG
Ankit Gupta
Numerade Educator
Use the MATLAB help facilities to determine what happens if you use the exp function with an imaginary argument.
Check back soon!
Suppose that $x=\{-15,-8,9,8,5]$ and $y=[-20,12,-4,8,9]$. What is the result of the following operations? Determine the answers by hand, and then use MATLAB to check your answers.
a. $z=(x<y)$
b. $z=(x>y)$
c. $z=(x==y)$
$$ \begin{aligned} & \text { d. } z=(x=-y) \\ & \text { e. } z=(y>-4) \end{aligned} $$
Check back soon!
Suppose that $x=[-15,-8,9,8,5]$ and $y=[-20,12,-4,8,9]$. Use MATLAB to find the values and the indices of the elements in $x$ that are greater than the corresponding elements in $y$.
Check back soon!
Write a script file using conditional statements to evaluate the following function, assuming that the scalar variable $x$ has a value. The function is $y=e^{x+1}$ for $x<-1, y=2+\cos (\pi x)$ for $-1 \leq x<5$, and $y=10(x-5)+1$ for $x \geq 5$. Use your file to evaluate $y$ for $x=-5$, $x=3$, and $x=15$, and check the results by hand.
Carson Merrill
Numerade Educator
Use a for loop to plot the function given in Problem 36 over the interval $-2 \leq x \leq 6$. Properly label the plot. The variable $y$ represents height in kilometers, and the variable $x$ represents time in seconds.
Jacquelyn Trost
Numerade Educator
Plot the function $y=10\left(1-e^{-x / 4}\right)$ over the interval $0 \leq x \leq x_{\max }$, using a while loop to determine the value of $x_{\max }$ such that $y\left(x_{\max }\right)=9.8$. Properly label the plot. The variable $y$ represents force in newtons, and the variable $x$ represents time in seconds.
Uma Kumari
Numerade Educator
Use a for loop to determine the sum of the first 10 terms in the series $5 k^3$, $k=1,2,3, \ldots 10$.
Charles Carter
Numerade Educator
Use a while loop to determine how many terms in the series $2^k, k=1,2$, $3, \ldots$, are required for the sum of the terms to exceed 2000 . What is the sum for this number of terms?
Harsh*ta Goel
Numerade Educator
One bank pays 5.5 percent annual interest, while a second bank pays 4.5 percent annual interest. Determine how much longer it will take to accumulate at least $$\$ 50,000$$ in the second bank account if you deposit $$\$ 1000$$ initially, and $$\$ 1000$$ at the end of each year.
Leslie Deeb
Numerade Educator
a. With what initial speed must you throw a ball vertically for it to reach a height of 20 ft ? The ball weighs 1 lb . How does your answer change if the ball weighs 2 lb ?
b. Suppose you wanted to throw a steel bar vertically to a height of 20 ft . The bar weighs 2 lb . How much initial speed must the bar have to reach this height? Discuss how the length of the bar affects your answer.
Sachin Rao
Numerade Educator
Consider the motion of the piston discussed in Example 1.7-1. The piston stroke is the total distance moved by the piston as the crank angle varies from $0^{\circ}$ to $180^{\circ}$.
a. How does the piston stroke depend on $L_1$ and $L_2$ ?
b. Suppose $L_2=0.5 \mathrm{ft}$. Use MATLAB to plot the piston motion versus crank angle for two cases: $L_1=0.6 \mathrm{ft}$ and $L_1=1.4 \mathrm{ft}$. Compare each plot with the plot shown in Figure 1.7-3. Discuss how the shape of the plot depends on the value of $L_1$.
AG
Ankit Gupta
Numerade Educator