Question: Matlab HW, needed before 5/2/2017 Write a function that accepts a variable number of input values and returns the sorted values as an array. The


Matlab HW, needed before 5/2/2017
Write a function that accepts a variable number of input values and returns the sorted values as an array. The function will be called, for example, like this: b mSort (2,1,4,3) and will return a vector ba [1 234] (either row or column vector is OK) The function should have the following features: (10 pts) Help text, including H1 (first line) (20 pts) optionally include a string parameter 'd' or 'D' to change the sort order to descending, i e., highest to lowest. It should be placed as the last argument to the function, i.e., b msort(2,1,4,3, d') returns [4 3 2 1] made during the sort process. If no sorting is done, the number of swaps will be zero. The function is then called as [b,n] msort(2,1,4,3); here b is assigned the sorted value as above, and n is the number of swaps that occurred during the sorting process. (10 pts) should work for only a single input argument, i e, msort(3) returns 3, rather than generating an error. (10 pts) Issue an error if anything other than a number or 'd' or 'D' is sent as an argument
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
