Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. Write a function that takes x as an INPUT VECTOR and provide the command(s) t

ID: 3682086 • Letter: 3

Question

3. Write a function that takes x as an INPUT VECTOR and provide the command(s) that will generate the new vector with the same dimension as x’s, by

a. Setting the values of x that are positive to zero (It means that you generate a new vector, let’s say a, a=x, and then set the elements of a are positive (> 0) to zero. Do similarly for the other part of this question).

b. Setting values that are multiples of 3 to 3 (rem function will help here)

c. Multiplying the values of x that are even by 5

d. Extract the values of x that are greater than 10 into a vector called y

e. Setting the values in x that are less than the mean to zero

f. Setting the values in x that are above the mean to their difference from the mean

Explanation / Answer

x = [3 15 9 12 -1 0 -12 9 6 1] a = x, idxa = x > 0, a(idxa) = 0 b = x, idxb = ~rem(x,3), b(idxb) = 3 c = x, idxc = ~rem(x,2), c(idxc) = 5*c(idxc)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote