Effacer les filtres
Effacer les filtres

Develop a matlab program that generates a 10x10 array of random integers and uses appropriate flow-control structures to search the grid and determine the maximum and minimum

46 vues (au cours des 30 derniers jours)
Develop a matlab program that generates a 10x10 array of random integers and uses appropriate flow-control structures to search the grid and determine the maximum and minimum value. Furthermore, the program should also output both the original and sorted version of the 10x10 array.
  2 commentaires
Steven Lord
Steven Lord le 4 Avr 2024 à 13:45
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the free MATLAB Onramp tutorial to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.
DGM
DGM le 4 Avr 2024 à 17:16
It's only mentioned that the array is supposed to be sorted, but it's not clear how it's suppsed to be sorted. Is the result a vector? Is it a 2D array with sorted rows? Sorted columns?

Connectez-vous pour commenter.

Réponses (1)

DGM
DGM le 4 Avr 2024 à 17:40
Modifié(e) : DGM le 4 Avr 2024 à 17:43
Want to see if your TA can tell you didn't do your own homework? Here's a fair test.
[~,A] = system('od -vAn -N200 -tu2 < /dev/urandom');
A = reshape(sscanf(A,'%d'),1E1,[])
A = 10x10
2373 3870 3848 28749 41063 38246 23539 60902 27531 43579 28116 53294 59283 28230 37298 40827 61730 60876 36047 58904 30891 20683 52218 14541 55216 27153 49383 27596 34206 44198 28929 56318 48308 5805 54477 16581 11885 21909 24261 60530 16467 44232 37431 49903 21805 28288 36529 56871 5250 57616 5191 4538 6098 46357 10059 26267 13043 10790 34319 45373 54695 2849 979 56109 4110 17160 12256 8753 63546 31071 31270 111 49831 34107 41323 5904 807 42191 46344 33870 63170 14022 46675 16370 3469 11916 1367 17481 18752 42820 9985 55426 24982 27987 61339 43240 23525 19205 33580 41087
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
A_sorted = intersect(A,A)
A_sorted = 100x1
111 807 979 1367 2373 2849 3469 3848 3870 4110
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
[Amin Amax] = bounds(A_sorted)
Amin = 111
Amax = 63546
I'm going to assume "output" means "dumps to console", and that "appropriate flow control statements" means "none".

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by