Effacer les filtres
Effacer les filtres

Group values of one column based of the values of another

1 vue (au cours des 30 derniers jours)
Priscilla
Priscilla le 25 Juil 2020
Réponse apportée : KSSV le 25 Juil 2020
Hi all,
I have a two column matrix, I would like to group y such that if x isbetween 0 and 0.7 then corresponding y values belong to subarray 1, if x isbetween 0.8 and 1.4, then corresponding y values belong to subarray 2 and so on. How can I go about this. Thanks in advance
sample from matrix [x y]=
0 0.2954
0.1000 0.0861
0.2000 -0.0204
0.3000 0.0046
0.4000 0.2297
0.5000 0.7651
0.6000 -0.4482
0.7000 -1.2974
0.8000 0.3673
0.9000 -0.7759
1.0000 0.5676
1.1000 1.0851
1.2000 0.4082
1.3000 0.3364
1.4000 -0.3396
1.5000 -0.1935
1.6000 0.5228

Réponse acceptée

KSSV
KSSV le 25 Juil 2020
If (x,y) are two column arrays you have. You can get values lying in between two values using:
idx = x>=0.8 & X<1.4 ;
y1 = y(idx) ;

Plus de réponses (0)

Catégories

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