How can I which value that be used to calculate a function
조회 수: 1 (최근 30일)
이전 댓글 표시
In this casue, I difine a range for x and y, and then calculated the min value of L, but how do i find which x vaule and y value to calculate the min L? Many thanks!!!!!
댓글 수: 0
채택된 답변
Fangjun Jiang
2019년 5월 14일
편집: Fangjun Jiang
2019년 5월 14일
You need to run min() twice
A=magic(5);
[MinInCol,RowIndex]=min(A);
[MinValue,ColIndex]=min(MinInCol);
Position=[RowIndex(ColIndex),ColIndex];
or better
[MinValue,Index]=min(A(:));
[Ix,Iy]=ind2sub(size(A),Index)
댓글 수: 2
Fangjun Jiang
2019년 5월 17일
Not clear what you mean. Maybe in your example, you are looking for x(Ix), y(Iy)?
추가 답변 (1개)
Steven Lord
2019년 5월 14일
Since you indicate that you're using release R2019a, call min with the 'linear' option and two output arguments. This will give you the linear index of the minimum value, and you can use that index into x and y.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!