Skip to content

ifelse (Series)

Replace time series values based on a test condition

Syntax

X = ifelse(X, Test, IfTrue, ~IfFalse)

Input arguments marked with a ~ sign may be omitted.

Input arguments

X [ TimeSubscriptable ]

Input time series.

Test [ function_handle ]

Test function that returns true or false for each observation.

IfTrue [ any | empty ]

Value assigned to observations for which the Test function returns true; if isempty, these observations will remain unchanged.

IfFalse [ any | empty ]

Value assigned to observations for which the Test function returns false; if isempty or omitted, these observations will remain unchanged.

Output arguments

X [ TimeSubscriptable ]

Output time series.

Options

zzz=default [ zzz | ___ ]

Description

Description

Examples