Find a range of minimum values in a vector/array
9 次查看(过去 30 天)
显示 更早的评论
Hello everyone! Briefly, I would like to ask if, in MATLAB, exists a function or something else to find a min or max range of values in an array. I mean, if I have [7 2 1 4 34 9 8 5]
And I want to find the a "range" of three numbers, which is the minimumin the array, MATLAB will give me as result
[2 1 4]
And so on.
Thanks in advice, A.M.
2 个评论
José-Luis
2013-5-6
What do you mean by "a range"? The three smallest numbers, or the three contiguous smallest numbers?
采纳的回答
Andrei Bobrov
2013-5-6
编辑:Andrei Bobrov
2013-5-6
I see two ways:
1)
out = sort(yourarray);
out = out(1:3);
2)
[ii,ii] = min(conv(yourarray,[1 1 1],'same'));
out = yourarray(ii-1:ii+1);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!