• Home
  • Textbooks
  • MATLAB Programming for Engineers
  • Introduction to MATLAB

MATLAB Programming for Engineers

Stephen J.Chapman

Chapter 1

Introduction to MATLAB - all with Video Answers

Educators


Chapter Questions

03:02

Problem 1

Answer the following questions for the array shown below.
$$
\text { array } 1=\left[\begin{array}{rrrrr}
1.1 & 0.0 & 2.1 & -3.5 & 6.0 \\
0.0 & 1.1 & -6.6 & 2.8 & 3.4 \\
2.1 & 0.1 & 0.3 & -0.4 & 1.3 \\
-1.4 & 5.1 & 0.0 & 1.1 & 0.0
\end{array}\right]
$$
a. What is the size of array 2?
b. What is the value of array $1(4,2)$ ?
c. What is the size and value of array $1(:, 1: 2)$ ?
d. What is the size and value of array $1([1,3]$, end) ?

Ernest Castorena
Ernest Castorena
Numerade Educator
07:11

Problem 1

The following MATLAB statements plot the function $y(x)=2 e^{-02 x}$ for the range $0 \leq x \leq 10$.
$x=0 ; 0.1: 10 ;$
$y=2 * \exp (-0.2 * x)=$
$\operatorname{plot}(x, y):$
Use the MATLAB Edit Window to create a new empty M-file, type these statements into the file, and save the file with the name test $1 . \mathrm{m}$. Then, execute the program by typing the name test 1 in the Command Window. What result do you get?

Robert Daugherty
Robert Daugherty
Numerade Educator
07:11

Problem 1

The following MATLAB statements plot the function $y(x)=2 e^{-02 x}$ for the range $0 \leq x \leq 10$.
$x=0: 0.1: 10 ;$
$y=2 * \exp (-0.2 \cdot x) ;$
$p 10 t(x, y):$
Use the MATLAB Edit Window to create a new empty M-file, type these statements into the file, and save the file with the name teat. 1 .m. Then, execute the program by typing the name test 1 in the Command Window. What result do you get?

Robert Daugherty
Robert Daugherty
Numerade Educator
02:17

Problem 2

Get help on the MATLAB function exp using: (a) The "help exp" command typed in the Command Window, and $(b)$ the Help Browser.

James Kiss
James Kiss
Numerade Educator
02:41

Problem 2

Are the following MATLAB variable names legal or illegal? Why?
a. $\operatorname{dog} 1$
b. $1 \mathrm{dog}$
c. Do_you_know_the_way_to_san_jose
d. help
e. What's_up?

Jeff Vermeire
Jeff Vermeire
Numerade Educator
02:17

Problem 2

Get help on the MATLAB function exp using: (a) The "help exp" command typed in the Command Window, and $(b)$ the Help Browser.

James Kiss
James Kiss
Numerade Educator
00:43

Problem 3

Use the lookfor command to determine how to take the base- 10 logarithm of a number in MATLAB.

Wendi Zhao
Wendi Zhao
Numerade Educator
00:44

Problem 3

Use the look for command to determine how to take the base-10 logarithm of a number in MATLAB.

Sherrie Fenner
Sherrie Fenner
Numerade Educator
00:21

Problem 3

Determine the size and contents of the following arrays. Note that the later arrays may depend on the definitions of arrays defined earlier in this exercise.
a. $a=1: 2: 5$;
b. $b=\left\{a^{+} a^{*} a^{*}\right\}$
c. $c=b(1: 2: 3,1: 2: 3)$;
d. $d=a+b(2,:)=$
c. $w=$ [zeros $(1,3)$ ones $(3,1), 3: 5^{*}$ ?
f. $b([1] 3], 2)=b([3,1], 2)=$

Thomas Emment
Thomas Emment
Numerade Educator
00:58

Problem 4

Suppose that $u=1$ and $v=3$. Evaluate the following expressions asing MATLAB.
a. $\frac{4 u}{3 v}$
b. $\frac{2 v^{-2}}{(u+v)^{2}}$
c. $\frac{v^{3}}{v^{3}-u^{3}}$
d. $\frac{4}{3} \pi y^{2}$

Caleb Fink
Caleb Fink
Numerade Educator
01:46

Problem 4

Use the MATLAB Help Browser to find the command required to show MATLAB's current directory. What is the current directory when MATLAB starts up?

James Kiss
James Kiss
Numerade Educator
00:58

Problem 4

Suppose that $u=1$ and $v=3$. Evaluate the following expressions asing MATLAB.
a. $\frac{4 u}{3 v}$
b. $\frac{2 v^{-2}}{(u+v)^{2}}$
c. $\frac{v^{3}}{v^{3}-u^{3}}$
d. $\frac{4}{3} \pi v^{2}$

Caleb Fink
Caleb Fink
Numerade Educator
01:29

Problem 4

Assume that array array 1 is defined as shown, and determine the contents of the following sub-arrays.
$$
\operatorname{array} 1=\left[\begin{array}{rrrrr}
1.1 & 0.0 & 2.1 & -3.5 & 6.0 \\
0.0 & 1.1 & -6.6 & 2.8 & 3.4 \\
2.1 & 0.1 & 0.3 & -0.4 & 1.3 \\
-1.4 & 5.1 & 0.0 & 1.1 & 0.0
\end{array}\right]
$$
a. array $1(3,4)$
b. array $1(:, 3)$
c. arxay $1\left(1: 2: 3,\left[\begin{array}{lll}3 & 3 & 4\end{array}\right]\right)$
d. array $1(\{1 \quad 1], 4)$

Joshua Eastwood
Joshua Eastwood
Numerade Educator
02:01

Problem 5

Assume that value has been initialized to $10 \pi$, and determine what is printed out by each of the following statements.

Erika Bustos
Erika Bustos
Numerade Educator
01:46

Problem 5

Use the MATLAB Help Browser to find the command required to show MATLAB's current directory. What is the current directory when MATLAB starts up?

James Kiss
James Kiss
Numerade Educator
03:31

Problem 6

Assume that $a, b, c$, and $d$ are defined as follows, and calculate the results of the following operations if they are legal. If an operation is illegal, explain why it is illegal.
$$
\begin{array}{ll}
a=\left[\begin{array}{rr}
2 & -2 \\
-1 & 2
\end{array}\right] & b=\left[\begin{array}{rr}
1 & -1 \\
0 & 2
\end{array}\right] \\
c=\left[\begin{array}{r}
1 \\
-2
\end{array}\right] & d=\text { eye }(2)
\end{array}
$$
a. result $=a+b$;
b. result $=a=d_{i}$
c. result $=a$. * $d$;
d. result $=a \cdot c$;
c. reault $=a . * c$ ?
f. result $=a \backslash b$ :
g. result $=a .1 \mathrm{~b}$ :
h. result $=a . A b$;

Adarsh Kumar
Adarsh Kumar
Numerade Educator
05:41

Problem 6

Use the MATLAB Help Browser to find out how to create a new directory from within MATLAB. Then, create a new directory called mynewdir under the current directory. Add the new directory to the top of MATLAB's path.

Amany Waheeb
Amany Waheeb
Numerade Educator
07:13

Problem 6

Use the MATLAB Help Browser to find out how to create a new directory from within MATLAB. Then, create a new directory called mymewdir under the current directory, Add the new directory to the top of MATLAB's path.

Victor Salazar
Victor Salazar
Numerade Educator
01:58

Problem 7

Evaluate each of the following expressions.
a. $11 / 5+6$
b. $(11 / 5)+6$
c. $11 /(5+6)$
d. $3 \wedge 2 \wedge 3$
e. 3 A $(2 \times 3)$
f. $(3-2) \wedge 3$
g. round $(-11 / 5)+6$
h. $\operatorname{cesin}(-11 / 5)+6$
i. Eloor $(-11 / 5)+6$

Julian Wong
Julian Wong
Numerade Educator
01:56

Problem 7

Change the current directory to mynewdir, Then open an Edit Window and add the following lines:
8 Create an input array from $-2$ *pi to $2 * \mathrm{pi}$
$t=-2 * \mathrm{pi}: \mathrm{p} 1 / 10: 2^{*} \mathrm{pi}$;
? Calculate |sin (t) |
$x=a b s(\sin (t)) ;$
- Plot result
plot $(t, x)=$
Save the file with the name test $2, m$, and execute it by typing test 2 in the Command Window. What happens?

Carson Merrill
Carson Merrill
Numerade Educator
01:56

Problem 7

Change the current directory to mynewdir. Then open an Edit Window and add the following lines:
8. Create an input array from $-2$ *pi to 2 *pi
$t=-2 * \mathrm{pi}: \mathrm{p} i / 10: 2^{\circ} \mathrm{pi}$;
of Calculate |sin(t)|
$x=a b s(\sin (t))$;
- Plot result
plot $(t, x)=$
Save the file with the name test2. $m$, and execute it by typing test 2 in the Command Window. What happens?

Carson Merrill
Carson Merrill
Numerade Educator
01:11

Problem 8

Use MATLAB to evaluate cach of the following expressions.
a. $(3-5 i)(-4+6 i)$
b. $\cos ^{-1}(1.2)$

Ian Shi
Ian Shi
Numerade Educator
01:33

Problem 8

Close the Figure Window, and change back to the original directory that MATLAB started in. Next type "test2" in the Command Window. What happens, and why?

Foster Wisusik
Foster Wisusik
Numerade Educator
01:33

Problem 8

Close the Figure Window, and change back to the original directory that MATLAB started in. Next type "test2" in the Command Window. What happens, and why?

Foster Wisusik
Foster Wisusik
Numerade Educator
01:21

Problem 9

Solve the following system of simultaneous equations for $x$. $-2.0 x_{1}+5.0 x_{2}+1.0 x_{3}+3.0 x_{4}+4.0 x_{5}-1.0 x_{6}=0.0$
$2.0 x_{1}-1.0 x_{2}-5.0 x_{3}-2.0 x_{4}+6.0 x_{5}+4.0 x_{6}=1.0$
$-1.0 x_{1}+6.0 x_{2}-4.0 x_{3}-5.0 x_{4}+3.0 x_{5}-1.0 x_{6}=-6.0$
$4.0 x_{1}+3.0 x_{2}-6.0 x_{3}-5.0 x_{4}-2.0 x_{5}-2.0 x_{6}=10.0$
$-3.0 x_{1}+6.0 x_{2}+4.0 x_{3}+2.0 x_{4}-6.0 x_{5}+4.0 x_{6}=-6.0$
$2.0 x_{1}+4.0 x_{2}+4.0 x_{3}+4.0 x_{4}+5.0 x_{5}-4.0 x_{6}=-2.0$

Weston Bell-Geddes
Weston Bell-Geddes
Numerade Educator