フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how to select matrix from many random matrix?

1 回表示 (過去 30 日間)
Firas Al-Kharabsheh
Firas Al-Kharabsheh 2016 年 5 月 3 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 5 月 3 日
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

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by