How to look for minimum value in a vector from backwards?

조회 수: 3 (최근 30일)
George Ansari
George Ansari 2017년 8월 23일
편집: José-Luis 2017년 8월 23일
Suppose I have a vector A = [5 6 4 1 1 1]; I'd like to find the index of a minimum value. If I try min function in a regular way:
[A_min index] = min(A)
it would give me somethin like:
A_min = 1
index = 4
But the result that I'm trying to get should be:
A_min = 1
index = 6
How do I search for a minimum value starting from the end of the vector without flipping it?
George.

채택된 답변

José-Luis
José-Luis 2017년 8월 23일
편집: José-Luis 2017년 8월 23일
A = [5 6 4 1 1 1];
A_min = min(A);
idx = find(A == A_min,1,'last')
Also
[A_min,idx] = min(fliplr(A));
idx = numel(A) - idx + 1

추가 답변 (1개)

KL
KL 2017년 8월 23일
find(A==A_min,1,'last')

카테고리

Help CenterFile Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by