Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started