Find a function that sorts each ith element in the vector by the largest of the preceding elements.
1 次查看(过去 30 天)
显示 更早的评论
Let x = [x_1, x_2, x_3, ..., x_N].
I want to make a vector y whose ith element is given as y_i = max {x_k | k<=i}.
For example, suppose that x is given as x=[1, 8, 3, 9, 11].
Then, I want to make y=[1, 8, 8, 9, 11].
Is there a function that does as above?
Actually, I can make a function that does as above, but I want to use built-in functions since the built-in functions are usually faster than my own.
Thank you for reading my question.
3 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!