First element greater than
조회 수: 25 (최근 30일)
이전 댓글 표시
I have a set of data containing x,
How can i extract only the first value greater than x in this set.
댓글 수: 0
채택된 답변
Star Strider
2022년 8월 17일
Try simething like this —
v = randi(9, 1, 20)
x = 7
first_x_idx = find(v > x,1,'first')
Result = v(first_x_idx)
.
댓글 수: 2
Star Strider
2022년 8월 17일
I am confused. I am not certain what you want.
I am not certain how robust this will be for other vectors, however here it gives the result you want —
v = [-0.1011 -0.0712 -0.0562];
x = -0.0599;
first_x_idx = interp1(v,(1:numel(v)),x,'previous')
Result = v(first_x_idx)
.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!