필터 지우기
필터 지우기

Array minimum

조회 수: 1 (최근 30일)
athpapa -
athpapa - 2011년 2월 11일
Hello,
I have a table, e.g.: 999 999 1 999 4 5 5 0 8 9
and I use the matlab function: [C,I] = min(...) to find the minimum value and index of the table! Is there any way to use this function with conditions? For example, I want from the above table the value 1 as the minimum and not 0. Or if there is two or more same minimums, e.g. 2 zeros, the function [C,I] = min(...) always return the first one found! Can I change its conditions to return the last one found?
Thank you very much....

답변 (1개)

Oleg Komarov
Oleg Komarov 2011년 2월 11일
A = [999 999 1 999 4 5 5 0 8 9 1];
val = min(A(A ~= 0));
find(A == val,1,'last')
Oleg

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by