# rec08 - b Write another version of the function that takes...

This preview shows page 1. Sign up to view the full content.

Recitation Problems – Week 8 440:127 – Fall 2011 – S. J. Orfanidis Please do the following problems during your recitation session, including any additional problems given to you by your TA. 1. Type in and observe the output of all the examples listed in pp. 6–12 of the week-7 lecture notes. 2. Try the examples on p. 25 and p. 29, experimenting with larger values of the threshold, e.g., replace the eps -parameter by 10 6 andthenby10 10 and observe how it affects the accuracy of the result. 3. Consider the piece-wise function: f(x) = ( 3 x + 2 ), if x ≤− 1 | x | , if 1 <x< 1 2 x x 2 , if x 1 a. Write a one-line anonymous MATLAB function that implements the above using relational operators and accepts an arbitrary vector x as input and computes the corresponding vector of outputs f(x) . Plot the function for x =− 2:0 . 01 : 2.
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: b. Write another version of the function that takes in a scalar x input and outputs the corresponding scalar f(x) . The function must be constructed using an explicit if-elseif-else-end construction. Use this function to evaluate and plot f(x) over the same range of x s as in part (a). 4. Consider the relational operation: k = (a < b); where a is a real-valued row vector and b is either a real-valued row vector of the same length as a , or, a scalar. Write a MATLAB function, k = f(a,b); that implements the same relational operation using for-loops and if-statements only. The output k must be of type logical . Test it on the two cases: a = [1 2 0 -3 7]; b = [3 2 4 -1 7]; a = [1 2 0 -3 7]; b = 3; 5. If time permits, do Practice Exercise 9.1 and 9.2 from Ch.9. 1...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online