フィルターのクリア

Find a function that sorts each ith element in the vector by the largest of the preceding elements.

1 回表示 (過去 30 日間)
Danny
Danny 2019 年 12 月 17 日
コメント済み: Adam Danz 2019 年 12 月 17 日
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 件のコメント
Danny
Danny 2019 年 12 月 17 日
x is input and y is ouput.
Adam Danz
Adam Danz 2019 年 12 月 17 日
ah, right....
Looks like Steven Lord hit the nail on the head.

サインインしてコメントする。

回答 (1 件)

Steven Lord
Steven Lord 2019 年 12 月 17 日
The cummax function computes the cumulative maximum of an array.

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by