7.14: Chapter Exercises
- Page ID
- 136679
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\dsum}{\displaystyle\sum\limits} \)
\( \newcommand{\dint}{\displaystyle\int\limits} \)
\( \newcommand{\dlim}{\displaystyle\lim\limits} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\(\newcommand{\longvect}{\overrightarrow}\)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\ket}[1]{\left| #1 \right>}\)
\(\newcommand{\bra}[1]{\left< #1 \right|}\)
\(\newcommand{\braket}[2]{\left< #1 \vphantom{#2} \right| \left. #2 \vphantom{#1} \right>}\)
\(\newcommand{\braopket}[3]{\left< #1 \vphantom{#2}\vphantom{#3} \right| #2 \vphantom{#1}\vphantom{#3} \left| #3 \vphantom{#1}\vphantom{#2} \right>}\)
\(\newcommand{\qmvec}[1]{\mathbf{\vec{#1}}}\)
\(\newcommand{\op}[1]{\hat{\mathbf{#1}}}\)
\(\newcommand{\expect}[1]{\langle #1 \rangle}\)
\(\newcommand{\dfn}[1]{\emph{\textbf{#1}}}\)
Exercise 1: Vector Maker
Write a script named vectorMaker that uses a loop to prompt the user to enter elements of a vector one at a time. If the user enters any letter, the program stops and prints the vector. If the user never enters a number, display a helpful message.
Exercise 2: Whitespace Counter
Write a function named whitespaceCounter that receives a string scalar and returns the number of whitespace characters. Your function must use isstrprop.
Exercise 3: Guest List
Write a function named isGuest that receives a name and a string array containing a guest list. The function should return one logical value indicating whether the name appears on the list. The comparison should ignore case.
Exercise 4: Split a Date
Write a function named splitDate that receives a date in a format such as 07-Feb-2008 and returns the day, month, and year as separate output arguments.
Exercise 5: Assembly Operation
Write a function named assemblyOperation that receives a string in one of the following forms: "Add n,m", "Subtract n,m", "Divide n,m", or "Multiply n,m". The function should return the result of the requested operation.
Exercise 6: Hidden Message
In cryptography, the intended message may consist of the first letter of every word in a sentence. Write a function named crypt that receives a character vector and returns the hidden message formed from the first letter of each word.
Exercise 7: Delete Multiple Blanks
Write a function named deleteMultipleBlanks that receives a string containing a sentence with extra blank spaces between some words. Return the sentence with only one blank space between words.
Exercise 8: Sine Calculator
Write a script named sine.m that prompts the user to enter an angle followed by r for radians or d for degrees. The script should use sin for radians and sind for degrees, then display the result.
Exercise 9: Username Cleaner
Write a function that receives a user name as text, removes leading and trailing spaces, converts it to lowercase, and replaces internal spaces with underscores.
Exercise 10: Simple Password Checker
Write a function that receives a password as text and checks whether it contains at least one uppercase letter, one lowercase letter, and one digit. Use isstrprop to help with the checks.


