Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个相当简单的例子,我想学习最好的解决方案。我有一个数据集:
depth = [0:0.5:20];
我只想从特定范围内选择“深度”,例如从 2 到 5。我可以通过以下方式执行此操作:
d1 = find(depth == 2,1,'first'); d2 = find(depth == 5,1,'first'); depth = depth(d1:d2);
有没有另一种更清洁的方式来做到这一点?
只需使用逻辑索引:
depth(depth >= 2 & depth <= 5)