Finding a point in data with FIND - accommodate both increasing and decreasing data
1 次查看(过去 30 天)
显示 更早的评论
Hello, I have data that I want to find the point closest to a threshold (th=800).
1728.00 1755.00 1778.00 1738.00 1810.00 1552.00 1274.00 924.00 668.00 407.00 202.00 132.00
then I use:
idx = single(find(data >= th, 1, 'last'));
However, sometimes the data is reversed so it would be 'first'.
idx = single(find(data >= th, 1, 'first'));
How can I accommodate both scenarios?
(For info, i then use this index to seed a more accurate value)
vq1 = interp1(line(yval-1:yval+1), x(yval-1:yval+1), th,'pchip'); % Interpolate In Region
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!