Write a user-defined function that sorts the elements of a vector from the largest to the smallest.

Question:

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.
Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: