Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxxviii Special Issue On Database And Expert Systems Applications Lncs 11250

Authors: Abdelkader Hameurlain ,Roland Wagner ,Sven Hartmann ,Hui Ma

1st Edition

3662583836, 978-3662583838

More Books

Students also viewed these Databases questions

Question

Perform the indicated operations 27st 2 - 18s 4 t + 9st /-9st

Answered: 1 week ago