is there any function that convert negative value to zero?

46 Ansichten (letzte 30 Tage)
Jinsu Kim
Jinsu Kim am 22 Nov. 2018
Beantwortet: Steven Lord am 22 Nov. 2018
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

Akzeptierte Antwort

Rik
Rik am 22 Nov. 2018
Bearbeitet: Rik am 22 Nov. 2018
somefunction=@(x) (abs(x)+x)/2;

Weitere Antworten (1)

Steven Lord
Steven Lord am 22 Nov. 2018
Use the max function with two inputs.

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by