is there any function that convert negative value to zero?

36 次查看(过去 30 天)
Hi guys~
What am now find is a function that retrun zero in case of negative inputs.
For example, A = [ 10 8 6 4 2 0 -2 -4 ] ;
somefunction(A) = [ 10 8 6 4 2 0 0 0 ] ;
Thanks in advances:D
Happy thanks giving day

采纳的回答

Rik
Rik 2018-11-22
编辑:Rik 2018-11-22
somefunction=@(x) (abs(x)+x)/2;

更多回答(1 个)

Steven Lord
Steven Lord 2018-11-22
Use the max function with two inputs.

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by