Cumulative minimum of an array - MATLAB Cody - MATLAB Central

Problem 42631. Cumulative minimum of an array

Difficulty:Rate

Find the cumulative minimum of an array without using the built-in function cummin (and a few others). Your function should act identically to cummin, allowing the same inputs.

Examples

If X = [0 4 3
        6 5 2]
cumin(X,1) is [0 4 3  and cumin(X,2) is [0 0 0
               0 4 2]                    6 5 2]
cumin(X,1,'reverse') is [0 4 2  and cumin(X,2,'reverse') is [0 3 3
                         6 5 2]                              2 2 2]
Also,
cumin([8 9 1 10 6 1 3 6 10 10]) returns [8 8 1 1 1 1 1 1 1 1]
cumin([8 9 1 10 6 1 3 6 10 10]') returns [8 8 1 1 1 1 1 1 1 1]'

See also cumax.

Solution Stats

52.0% Correct | 48.0% Incorrect
Last Solution submitted on Mar 20, 2025

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
4
8
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Problem Recent Solvers38

Community Treasure Hunt

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

Start Hunting!