Question: 27. Write a user-defined function that sorts the elements of a vector from the largest to the smallest. For the function name and arguments, use
27. Write a user-defined function that sorts the elements of a vector from the largest to the smallest. For the function name and arguments, use y=downsort(x). The input to the function is a vector x of any length, and the output y is a vector in which the elements of x are arranged in a descending order. Do not use the MATLAB built-in functions sort, max, or min. Test your function on a vector with 14 numbers (integers) randomly distributed between –30 and 30. Use the MATLAB randi function to generate the initial vector.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
