필터 지우기
필터 지우기

finding certain points in data

조회 수: 1 (최근 30일)
harley
harley 2015년 9월 2일
댓글: harley 2015년 9월 3일
hello,
if I have a row of data say:
x = 1, 1.4, 2, 2.2, 3, 3.7, 4.....
where the corresponding
y = 2, 3, 1, 6 ,5, 1, 5......
how do I pick the Y values that correspond to x = 1, 2, 3, 4 only
I have a few thousand points to search through and would appreciate some guidance.
thanks

채택된 답변

Walter Roberson
Walter Roberson 2015년 9월 2일
If you have a list of desired x points and they are not integral then
ysubset = interp1(x, y, xsubset, 'nearest');
If you have R2015a or newer you could use
[tf, idx] = ismembertol(xsubset, x);
xfound = xsubset(tf);
ysubset = ysubset(idx(tf));
The interp1 and ismembertol techniques can also be used if your target x are integers. However, if your criteria is that you want to extract all of the values that correspond to integer x and leave out the others then,
tf = x == floor(x);
xsubset = x(tf);
ysubset = y(tf);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by