Question: IN MATLAB PROGRAMMING PLEASE! Write a function vector sort that takes an arbitrary-length vector as input, sorts the elements in ascending or descending order, depending

IN MATLAB PROGRAMMING PLEASE!
 IN MATLAB PROGRAMMING PLEASE! Write a function vector sort that takes

Write a function vector sort that takes an arbitrary-length vector as input, sorts the elements in ascending or descending order, depending on the second input (which should be a string) and returns the sorted vector. If the second input is anything other than 'ascending' or 'descending' the function should print a warning and return the input vector unchanged. Use nested conditional structures and loops as necessary. (Do NOT use the built-in MATLAB function sort.) FOLLOW THE PROGRAM DESIGN STEPS DISCUSSED IN THE LECTURE. (Steps 2-4. must be submitted with your solution, they can be done on paper or in a text editor) STEP 2. Describe your sorting algorithm in detail. Use a variant of "Bubble Sort" STEP 3. Specify input/output arguments and program scope. STEP 4. Write a detailed structure plan implementing your algorithm that satisfies the program scope you specified. STEP 5. Write the function vector _sort based on YOUR structure plan. STEP 6. Verify validate your program. Use your function to sort the following vectors and return/output the sorted vector: - a = [7 4 -4 9 -10],'ascending 'AND ' descending' -b = [0 -1 3 4 5],' ascending' AND ' descending' - c = [-1 6 2 2 -7], 'ascending 'AND ' descending' - d = [4, 5 -16.12 10.1 10 -16.11 14 -3 2]. 'ascending' AND 'descending' - a = [7 4 -4 9 -10], 'up

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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

Students Have Also Explored These Related Databases Questions!