cumminCumulative minimum
m = cummin(A)A is a numeric or character array.m contains the cumulative minima and has the same size as A.A is complex, it first compares the magnitudes (i.e., moduli) of the complex numbers. If they have the same magnitudes, then it compares their phase angles.A.m = cummin(A, dim)A is a numeric or character array.dim should be a positive integer scalar, not equal to inf nor nan.dim-th dimension of A.size(A, dim) == 1 or dim > ndims(A), then m is the same as A.m = cummin(A, option)A is a numeric or character array.option should be either 'reverse', 'forward', 'includenan' or 'omitnan'.NaN in the operation.m = cummin(A, dim, option)m = cummin(A, dim) above, except that an option can be specified for controlling the operation direction or inclusion of NaN in the operation.m = cummin(A, option1, option2)m = cummin(A, option) above, except that two options can be specified at the same time.option2 will override option1 if they contradict with each other.m = cummin(A, dim, option1, option2)m = cummin(A, dim, option) above, except that two options can be specified at the same time.option2 will override option1 if they contradict with each other.| Option | Meaning | Default |
|---|---|---|
'forward' | The cumulative minima are obtained in the forward direction. | Default for cumsum, cumprod, cummin, cummax |
'reverse' | The cumulative minima are obtained in the reverse direction. | Not default for cumsum, cumprod, cummin and cummax |
'includenan' | Include NaN in the operation | Default for cumsum, cumprod |
'omitnan' | Omit NaN in the operation | Default for cummax, cummin |
A is the first dimension. The minimum operation is performed along the vertical direction. For instance, m(:,1) contains cumulative minima of elements of A(:,1).% Matrix of size [3,4]
A = reshape(1:12,3,4)
% Cumulative minima
m = cummin(A)
A =
1.000 4.000 7.000 10.00
2.000 5.000 8.000 11.00
3.000 6.000 9.000 12.00
m =
1.000 4.000 7.000 10.00
1.000 4.000 7.000 10.00
1.000 4.000 7.000 10.00
m(1,:) contains cumulative minima of elements of A(1,:).% Matrix of size [3,4]
A = reshape(1:12,3,4)
% Cumulative minima along 2nd dimension
m = cummin(A,2)
A =
1.000 4.000 7.000 10.00
2.000 5.000 8.000 11.00
3.000 6.000 9.000 12.00
m =
1.000 1.000 1.000 1.000
2.000 2.000 2.000 2.000
3.000 3.000 3.000 3.000
cummin by default omits NaN, therefore the NaN in a is ignored in the first call of cummin. In the second call of cummin, NaN is included in the comparison. Therefore, NaN appears in the output since comparison with NaN returns NaN.a = [1:5 nan 6]
% Default options
disp('Omit nan, forward')
cummin(a)
% Include nan, forward direction
disp('Include nan, forward.')
cummin(a, 'includenan')
% Omit nan, forward direction
disp('Omit nan, forward')
cummin(a, 'omitnan')
% Omit nan, forward direction
disp('Omit nan, forward')
cummin(a, 'forward')
% Omit nan, reverse direction
disp('Omit nan, reverse')
cummin(a, 'reverse')
a =
1.0000 2.0000 3.0000 4.0000 5.0000 NaN 6.0000
Omit nan, forward
ans =
1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
Include nan, forward.
ans =
1.0000 1.0000 1.0000 1.0000 1.0000 NaN NaN
Omit nan, forward
ans =
1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
Omit nan, forward
ans =
1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
Omit nan, reverse
ans =
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 6.0000