finding certain points in data
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
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개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!