필터 지우기
필터 지우기

Group values of one column based of the values of another

조회 수: 3 (최근 30일)
Priscilla
Priscilla 2020년 7월 25일
답변: KSSV 2020년 7월 25일
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

채택된 답변

KSSV
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개)

카테고리

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