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

1 view (last 30 days)
summyia qamar
summyia qamar on 12 Jan 2017
Commented: summyia qamar on 12 Jan 2017
if I have a cell A and cell B
for i=1:A
for j=1:B
do something
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?

Answers (1)

Jan on 12 Jan 2017
Result = zeros(A, B);
for i = 1:A
for j = 1:B
Result(i, j) = randi(3);
minValue = min(Result);
index = find(Result == minValue);
  1 Comment
summyia qamar
summyia qamar on 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

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!