Question: Initialize a vector v with the following values: 8 3 -9 12 -5 1 8 11 5 Write a MATLAB program that uses a for-loop
Initialize a vector v with the following values:
8 3 -9 12 -5 1 8 11 5
Write a MATLAB program that uses a for-loop and nested if-statements to make a copy of v (call it vNew) with the values in v transformed as follows: divide each positive even element in v by 4, multiply each positive odd element of v by 3, and double the negative elements in v. Then, output the new vector to the screen as follows: The new vector is: 2 9 -18 3 -10 3 2 33 15 Also, output the sum of the values in the new vector: The sum of the new vector is 39
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
