Skip to main content
Contents
Calc
Dark Mode Prev Next Profile
\(\newcommand\DLGray{\color{Gray}}
\newcommand\DLO{\color{BurntOrange}}
\newcommand\DLRa{\color{WildStrawberry}}
\newcommand\DLGa{\color{Green}}
\newcommand\DLGb{\color{PineGreen}}
\newcommand\DLBa{\color{RoyalBlue}}
\newcommand\DLBb{\color{Cerulean}}
\newcommand\ds{\displaystyle}
\newcommand\ddx{\frac{d}{dx}}
\newcommand\os{\overset}
\newcommand\us{\underset}
\newcommand\ob{\overbrace}
\newcommand\obt{\overbracket}
\newcommand\ub{\underbrace}
\newcommand\ubt{\underbracket}
\newcommand\ul{\underline}
\newcommand\tikznode[3][]
{\tikz[remember picture,baseline=(#2.base)]
\node[minimum size=0pt,inner sep=0pt,#1](#2){#3};
}
\newcommand\del{\nabla}
\newcommand\R{\mathbb{R}}
\newcommand\C{\mathcal{C}}
\newcommand\N{\mathcal{N}}
\newcommand\eps{\varepsilon}
\renewcommand\epsilon{\varepsilon}
\renewcommand\subset{\subseteq}
\newcommand\norm[1]{\|{#1}\|}
\newcommand\matrixbrackets[4][1]{
\draw (#3,#2) -- (\fpeval{#3+0.2},#2);
\draw (#3,#1) -- (#3 ,#2);
\draw (#3,#1) -- (\fpeval{#3+0.2},#1);
\draw (#4,#2) -- (\fpeval{#4-0.2},#2);
\draw (#4,#1) -- (#4 ,#2);
\draw (#4,#1) -- (\fpeval{#4-0.2},#1);
}
\tikzstyle{circle node 0}=[fill=white, draw=black, shape=circle, inner sep=0pt]
\tikzstyle{circle node 2}=[fill=white, draw=black, shape=circle, inner sep=2pt]
\tikzstyle{hrect node}=[fill=white, draw=black, inner sep=2pt, outer sep=3pt]
\tikzstyle{vrect node}=[fill=white, draw=black, inner sep=0pt, outer sep=0pt]
\tikzstyle{hidden node 0}=[inner sep=0pt, outer sep=0pt]
\tikzstyle{hidden node 2}=[fill=white, inner sep=2pt, outer sep=2pt]
\tikzstyle{rect node 1}=[fill=white, inner sep=2pt, outer sep=0pt]
\tikzstyle{rect node 2}=[fill=white, draw=black, inner sep=2pt, outer sep=0pt]
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Exercises π€π Conceptual Questions
1.
(a) Logical Data Types.
In MATLAB,
true and
1 are the same.
True.
Incorrect. While true and 1 are represented by the same numeric value, they have different data types: true is of type logical, while 1 is of type double.
False.
Incorrect. While true and 1 are represented by the same numeric value, they have different data types: true is of type logical, while 1 is of type double.
(b) Relational Operators: Inequality.
Which of the following commands test that
x is not equal to
y?
~(x = y)
~(x == y)
~x == y
x ~= y
x ~== y
(c) Translating Relational Operators.
(d) Basic Logical Operators.
Select the value contained in
ans after evaluating the following expression:
ans = (3 >= 2) & (3+4 == 6)
ans = 1 (logical)
Incorrect. While 3 >= 2 is true, check the second part: is \(3+4\) really equal to \(6\text{?}\)
ans = 0 (logical)
Correct! Even though 3 >= 2 is true, the expression 3+4 == 6 is false (since \(3+4=7\) ). For an AND operation to be true, both sides must be true.
ans = 1
Incorrect. The result of a logical operation is always of type logical, not double.
ans = 0
Incorrect. The result of a logical operation is always of type logical, not double.
None of the above. This expression will produce an error.
(e) Understanding AND.
An AND operation (
&) returns true if at least one of the conditions is true.
True.
Incorrect. An AND operation requires both conditions to be true. Youβre thinking of OR (|), which returns true if at least one condition is true.
False.
Incorrect. An AND operation requires both conditions to be true. Youβre thinking of OR (|), which returns true if at least one condition is true.
(h) Combining with AND.
Select the command that is equivalent to asking the question:
Is
p a negative number greater than
-4?
p < 0 & p >= -4
p <= 0 | p > -4
-4 < p < 0
p < 0 | p > -4
p < 0 & p > -4
(i) Negating with NOT.
Which logical statements are equivalent to asking the question:
~(p > 0)
p <= 0
~p > 0
p ~> 0
p < 0
(k) Operator Precedence.
Select the logical statement that is equivalent to the following:
((~A) & B) | C
~(A & B | C)
~A & (B | C)
~(A & B) | C