Calculate the positive part of a function
xp = subplus(x)
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.
xp
x
0
max(x,0)
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.
spmak(0:2,1)
Function of which you want to calculate the positive part, specified as a scalar, vector, or matrix.
Data Types: single | double
single
double
Positive part of x, returned as a scalar, vector, or matrix.
fit | spline
spline