Group values of one column based of the values of another
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
KSSV
2020-7-25
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) ;
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!