have been practicing questions i see online i just cant get how to solve this mathwork
1 view (last 30 days)
Write a function called flip_it that has one input argument, a row vector v , and one output argument, a row vector w that is of the same length as v. The vector w contains all the elements of v, but in the exact opposite order. For example, if v is equal to [1 2 3] then w must be equal to [3 2 1]. You are not allowed to use the built-in function flip, fliplr, or flipud.
Chandrika on 17 Jun 2022
As per my understanding, you need to code for a function that reverses a vector. You can do this using a recursive function. Please try the following code:
elseif length(v) > 1
Here, recursion stops when length of the vector is 1, else flip_it function keeps getting called as part of the recursion.