MATLAB 帮助中心
Calculate positive part of function
xp = subplus(x)
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)
example
collapse all
Compute the positive part of integers in the range from -2 to 2 by using the subplus function.
subplus
x = -2:2; xp = subplus(x);
Plot the subplus function on the interval from -2 to 2.
plot(x,xp) ylim([-0.5 2.5])
Create a hat function by creating an anonymous function hat that uses the subplus function.
hat
hat = @(x) subplus(x) - 2*subplus(x-1) + subplus(x-2);
Plot the hat function on the interval from -0.5 to 2.5.
x = -0.5:0.5:2.5; plot(x,hat(x)) xlim([-0.5 2.5])
You can also describe the hat function by using the spline spmak(0:2,1).
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.
Introduced in R2006b
spline | fit
spline
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处