Question: Problem 3 (15 points): Recall problem 3 in homework 6. 1 Write a function mydsort that receives one vector as input argument, sorts the vector

 Problem 3 (15 points): Recall problem 3 in homework 6. 1

Problem 3 (15 points): Recall problem 3 in homework 6. 1 Write a function mydsort that receives one vector as input argument, sorts the vector in descending order, and return the sorted vector as output argument, using for-loop. For example, if the input vector vec-17 9 8 9 3 -8-5 10 10], then the output vector outve 10 10 9 9 7 3 1-5-8-8]. This function should work generally for any kind of input vectors (such as vectors that contain random numbers) 3.2 Test your function in the MATLAB Command window by generating a 1-by-10 row vector that contains random integer numbers in the inclusive range [-10 10] For example, vec-randi-10 10,, 10) vec = 4 -10 -5 -10 -8 7 4 -4 9 -10 ovecmydsort (vec) ovec = 9 7 4 4 -4 -5 -8 10 10 -10 Hints: To finish this function, nested for-loop and algorithm of exchanging two variables are needed. There is one built-in MATLAB function sort that can realize the same function. Try it sortivec, 'descend)

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!