Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

how to select matrix from many random matrix?

1 Ansicht (letzte 30 Tage)
Firas Al-Kharabsheh
Firas Al-Kharabsheh am 3 Mai 2016
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
if i write this code
for k=1:25
x = randi([0 1],5,5);
val = sum(sum(x))
end
the result will be 10 matrices that have the Minimum Val from the 25 Matrices
  • i need the Matrix not the value for matrices

Antworten (1)

Walter Roberson
Walter Roberson am 3 Mai 2016
Matrix = randi([0 1],5,5);
bestval = sum(Matrix(:));
for k = 2 : 25
x = randi([0 1],5,5);
val = sum(x(:));
if val < bestval
Matrix = x;
bestval = val;
end
end

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by