Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

how to select matrix from many random matrix?

5 visualizaciones (últimos 30 días)
Firas Al-Kharabsheh
Firas Al-Kharabsheh el 3 de Mayo de 2016
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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

Respuestas (1)

Walter Roberson
Walter Roberson el 3 de Mayo de 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

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by