Find the cumulative maximum of an array without using the built-in function cummax (and a few others). Your function should act identically to cummax, allowing the same inputs.
Examples
If X = [0 4 3
6 5 2]
cumax(X,1) is [0 4 3 and cumax(X,2) is [0 4 4
6 5 3] 6 6 6]
cumax(X,1,'reverse') is [6 5 3 and cumax(X,2,'reverse') is [4 4 3
6 5 2] 6 5 2]
Also,
cumax([8 9 1 10 6 1 3 6 10 10]) returns [8 9 9 10 10 10 10 10 10 10]
cumax([8 9 1 10 6 1 3 6 10 10]') returns [8 9 9 10 10 10 10 10 10 10]'
Solution Stats
Problem Comments
3 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers41
Suggested Problems
-
Read a column of numbers and interpolate missing data
2350 Solvers
-
Spherical radius given four points
254 Solvers
-
Return the first and last characters of a character array
11861 Solvers
-
Rotate input square matrix 90 degrees CCW without rot90
683 Solvers
-
Finding neighbors of [-1:1] in a matrix....
86 Solvers
More from this Author43
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
There is a problem is the first test.
Remove the assert(isempty(strfind(filetext,'max'))) because the name of the function cumax contains the string max.
Thank you.
@Matthew, could you be so kind and fix the first test? As it is, it is impossible to solve this problem since the function name "cumax" itself contains the string "max".
This also makes it impossible to obtain the Matrix Manipulation III badge.
The test suite has been updated temporarily.