Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

how to select matrix from many random matrix?

1 visualizzazione (ultimi 30 giorni)
Firas Al-Kharabsheh
Firas Al-Kharabsheh il 3 Mag 2016
Chiuso: MATLAB Answer Bot il 20 Ago 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

Risposte (1)

Walter Roberson
Walter Roberson il 3 Mag 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

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by