next up previous
Next: About this document ...

ESC 251 HW 12 Due: Oct. 1

Remember to indent the bodies of your IF-THEN and looping structures.



1)
(8 pts) Write a MATLAB script that will do the following:
a)
Load the data file hw12_1.dat into a vector x.
b)
Determine the number of elements in the vector x.
c)
Determine the total number of negative values and the total number of positive values in the vector using a for loop.
2)
(5 pts) Consider the function

\begin{displaymath}y = \left\{
\begin{array}{ll}
x^2-1 & \mbox{if}\,\,\,x \,\,\...
... x \,\,\,\mbox{is not divisible by 3} \\
\end{array}
\right. \end{displaymath}

Write a MATLAB script that will generate a vector x containing the elements from -20 to 20 in steps of 1, then evaluates the function y for this vector using a for loop.





2018-09-28