extracting all the values from an iteration which gives the same result(minimum value from loop)
조회 수: 1 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (1개)
Jan
2017년 1월 12일
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);
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!