subplus

Calculate the positive part of a function

Description

example

xp = subplus(x) returns the positive part of x, (x)+, which is x if x is nonnegative, and 0 if x is negative. In other words, xp equals max(x,0). If x is an array, this operation is applied entry by entry.

Examples

collapse all

This code generates and plot the essential part of the subplus function.

x = -2:2; plot(x,subplus(x),'linew',4), axis([-2,2,-.5,2.5])

The following anonymous function describes the so-called hat function:

hat = @(x) subplus(x) - 2*subplus(x-1) + subplus(x-2);

This is the spline also given by spmak(0:2,1), as the following plot shows.

Input Arguments

collapse all

Function of which you want to calculate the positive part, specified as a scalar, vector, or matrix.

Data Types: single | double

Output Arguments

collapse all

Positive part of x, returned as a scalar, vector, or matrix.

Introduced in R2006b