필터 지우기
필터 지우기

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개)

Steven Lord
Steven Lord 2019년 12월 17일
The cummax function computes the cumulative maximum of an array.

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by