Question: MATLAB Help: Create a 1 by 15 row vector of random integers between 1 and 20, then create one random integer between 5 and 15.

MATLAB Help:

Create a 1 by 15 row vector of random integers between 1 and 20, then create one random integer between 5 and 15. Sort your vector according to how far away each of its elements is from that scalar integer, in the descending order of the absolute distance. Hint: use the sort() function.

example run:

The original vector is [12 10 1 7 4 16 7 11 4 13 6 14 14 15 10]]

Sorted by the distance away from 5,

from far to near, the new vector is [16 15 14 13 12 11 10 10 1 7 7 4 4 6]

-----

Thank you for the help!

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!