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

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

3.45 Rating (165 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Script file xrandi30 ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (1 attachment)

Word file Icon

652-B-F-F-M (746).docx

120 KBs Word File

Students Have Also Explored These Related Finance Questions!