extracting all the values from an iteration which gives the same result(minimum value from loop)

1 vue (au cours des 30 derniers jours)
if I have a cell A and cell B
for i=1:A
for j=1:B
do something
end
end
minValue=min(#do somthing)
final=[A(i) B(j) minValue]
if e.g minValue is 6 which is obtained by doing operations on all combinations of A,B, the * final* gives 1 value of A and 1 value of B for the corresponding minValue.. how can we extract all the As and Bs which give the same minValue?

Réponses (1)

Jan
Jan le 12 Jan 2017
Result = zeros(A, B);
for i = 1:A
for j = 1:B
Result(i, j) = randi(3);
end
end
minValue = min(Result);
index = find(Result == minValue);
  1 commentaire
summyia qamar
summyia qamar le 12 Jan 2017
ok. understood this..what if A and B are matrices with different sizes let say A=6x7 and B=7x3 and minValue is one single value

Connectez-vous pour commenter.

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by