Effacer les filtres
Effacer les filtres

determing if number is in row of matrix

1 vue (au cours des 30 derniers jours)
Filipa Cardoso
Filipa Cardoso le 18 Avr 2018
Réponse apportée : KSSV le 18 Avr 2018
I have a matrix that represents an interval and i also have a number (x). the first column of the matrix represents the beginning of the interval and the second one represents the end. my goal is to determine if the x is between any of the numbers of the matrix. how can i do that?
matrix=[100 130;150 230; 250 270; 275 285; 290 315]
x= 225

Réponse acceptée

KSSV
KSSV le 18 Avr 2018
matrix=[100 130;150 230; 250 270; 275 285; 290 315] 
x= 225 ;
idx = matrix(:,1)<=x & matrix(:,2)>=x 
iwant = matrix(idx,:)

Plus de réponses (0)

Catégories

En savoir plus sur Shifting and Sorting Matrices 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