Question: Write a function that, given a 1D vector as the input calling argument, returns the reversed version of that vector. You must use a loop
Write a function that, given a 1D vector as the input calling argument, returns the reversed version of that vector.
You must use a loop with the appropriate indexing to accomplish this task.
Note that this is not asking to sort the elements into ascending or descending order.
Note that the result is returned by the function, not printed by the function.
For example, given an input [1 2 10 4 5], the reversed would be [5 4 10 2 1].
For example, given an input [1 3 5 6 4 2], the reversed would be [2 4 6 5 3 1].
For example, given an input [1 1 1 3 3 3 2 2 2], the reversed would be [2 2 2 3 3 3 1 1 1]
(For extra credit, as a commented line, include a single Matlab statement that accomplishes the same task.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
