How to find the minimum of an array element, but in a interval?
14 次查看(过去 30 天)
显示 更早的评论
I have an array A=[0.5 3 10]
I want x=3.
In general how to extract from an array minimum element in a interval. In this case is between for example between 1 and inf.
2 个评论
Dyuman Joshi
2023-10-31
移动:Dyuman Joshi
2023-11-2
Use logical indexing (Find Array Elements That Meet a Condition) to find the values in the given range and then use min.
采纳的回答
Beñat Arribas
2023-10-31
I propose you a simple way to do that.
You can filter from the array the numbers that are in the interval first:
A=[0.5 3 10];
A_new = A(>=1 & A<inf)
This way A_new will contain the values A_new=[3, 10]. Then you can use the min() function:
minimum = min(A_new)
Hope it answers your question!
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!