Question: Write a function modvec that will receive a vector of real numbers. If the sum of the components of the input vector is less than

 Write a function modvec that will receive a vector of real

Write a function modvec that will receive a vector of real numbers. If the sum of the components of the input vector is less than 7, the function will return a vector that is equal to the input vector. However, if the sum is greater than or equal to 7 but less than 20, the function will create and return a vector of equal size as the input vector with each component value equal to the corresponding component value of the input vector if that component value is less than 4, otherwise equal to half the component value of the input vector. Finally, if the said sum is greater than or equal to 20, the function outputs 0. Here are some examples of calling the function, with expected results: Problem 3. modvec(3-4 8 1-2]) ans 3-481-2 >>modvec([1 10 11 -3 -2] 15 5.5 -3-2 ans >modvec([-4 8 2-2-1]) ans -482-2-1 >modvec([-12 19 7 -2 9]) ans

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!