Find the under condition min or max of a row vector

16 vues (au cours des 30 derniers jours)
SOUGLES STAMATIS
SOUGLES STAMATIS le 11 Jan 2021
Commenté : KSSV le 11 Jan 2021
Assume that you have a row vector a = [ 1 3 5 2 5 7 8 3 6 4 9 ] . I want to find in which colomn there is the min value of this vector but under condition that this min value is >= 3 . Can enyone help?

Réponse acceptée

KSSV
KSSV le 11 Jan 2021
a = [ 1 3 5 2 5 7 8 3 6 4 9 ] ;
a(a<3) = NaN ; % Replace values <3 to NaN
[val,idx] = min(a)
  5 commentaires
SOUGLES STAMATIS
SOUGLES STAMATIS le 11 Jan 2021
Modifié(e) : SOUGLES STAMATIS le 11 Jan 2021
that returns the actual values ( 3 and 5 ). I need the column number ( 4 and 9 in this case)
KSSV
KSSV le 11 Jan 2021
find(~isnan(a),1,'first')
find(~isnan(a),1,'last')

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by