Help with Sorting Numbers?
Mostra commenti meno recenti
I've been asked to create a while loop that will sort all the randomly generated integers from smallest to largest. I'm given this code:
quantity = input(‘Please enter the number of random integers you would like to sort:\n’);
numbers = randi(100,1,quantity);
Could I have some help please? I have no idea where to start with this. Thank you.
Risposte (1)
Ameer Hamza
il 30 Apr 2020
If this is not a homework question, then you can simply use sort(): https://www.mathworks.com/help/matlab/ref/sort.html
result = sort(numbers)
If it is a homework question, then I cannot write the code, but I can point you to resources where you can study the implementation of other people and then write your own code for your assignment. See this FEX submission: https://www.mathworks.com/matlabcentral/fileexchange/52077-simple-sorting-methods. It provides MATLAB implementations of different sorting algorithms. You can read more about these algorithms from the following links
Categorie
Scopri di più su Shifting and Sorting Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!