Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

Students also viewed these Databases questions

Question

5 9 . : o

Answered: 1 week ago

Question

Solve for x: 2(3x 1)2(x + 5) = 12

Answered: 1 week ago