Colon operator vs. linspace, abs, sign. Do the following. Create a row vector wi
ID: 3598773 • Letter: C
Question
Colon operator vs. linspace, abs, sign. Do the following. Create a row vector with linearly spaced values with starting value of -k, final value of k, and 501 elements. Assign the created vector as variable vec o The value of k will be randomized at each submission, and will be created by the auto grader. Do not modify the given value of k. Find the absolute values of each element in vec, using abs function. Assign the result Find the signs of each element in vec, using sign function. Assign the result as variable . Look at the plot generated for you. What does abs do? What does sign do? You will o Note: sometimes, there can be a numerical error, sign(0) should be 0, however, o Note: k will be a positive real number. as variable abs vec. sign vec. not be graded on this answer, but try to figure this out for the learning purpose. it is +1 instead. This happens when 0 is not absolutely 0, sign (0.000001) = +1. Hint: Consider the choice between using colon operator and linspace. Which one is the appropriate (easier to use) one here?Explanation / Answer
linspace(-k, k, 501) % this is how you can create 501 points which are linearly spaced out abs_vec = abs(vec) % abs function return absolute value of each entry in a vector abs_vec = sign(vec) % sign function provide a vector of sign of individual entry