Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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!
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started