Question: 2. (8 points) A vector is given by v = [16, 13, -19, 110, 15, 10, -18, 111, -15]. Write a MATLAB program (a3q2.m) that

 2. (8 points) A vector is given by v = [16,

2. (8 points) A vector is given by v = [16, 13, -19, 110, 15, 10, -18, 111, -15]. Write a MATLAB program (a3q2.m) that creates the vector v, then uses a for-loop and nested if-statements to (i) divide each positive even element of v by 2, (ii) multiply each positive odd element of v by 3, and (iii) square (i.e., raise to the power 2) each of the negative elements. Then, output the new vector to the screen as The new vector is: 8 36 361 55 45 5 324 333 225

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!