In a array, finding x for the first instance of y.
3 次查看(过去 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 中查找有关 MATLAB Report Generator 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!