In a array, finding x for the first instance of y.
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a 2d array where x is time and y is result. I am trying to find the first time when y==1.
댓글 수: 0
채택된 답변
Star Strider
2021년 4월 8일
Depending on what you want:
idx = find(y>=1, 1, 'first');
time = x(idx);
or:
idx = find(y>=1, 1, 'first');
time = interp1(y(idx-2:idx), x(idx-2:idx), 1);
The interpolation works if ‘y’ is not exactly equal to 1 and you want to know what that interpolated time would be.
Choose the approach that works best in the context of your problem.
댓글 수: 0
추가 답변 (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!