Page 1 of 1

Question 2 Write the code for a function called mysteryFunction that takes in a vector, V, and produces a new vector, W,

Posted: Wed Apr 27, 2022 3:44 pm
by answerhappygod
Question 2
Write the code for a function called mysteryFunction that takes
in a vector, V, and produces a new vector, W, of the same length as
V where each element of W is the sum of the corresponding element
in V and the previous element of V. Consider the previous element
of V(1) to be 0. E.g. V = [1:6] mysteryFunction(V) should return [1
3 5 7 9 11]
Question 5
Write a PYTHON function d = dsc(c) that takes a one-dimensional
array of numbers c and returns an array d consisting of all numbers
in the array c with all neighbouring duplicated numbers being
removed. For instance, if c = [1 2 2 2 3 1], then d = [1 2 3
1].