is there any function that convert negative value to zero?

48 visualizaciones (últimos 30 días)
Jinsu Kim
Jinsu Kim el 22 de Nov. de 2018
Respondida: Steven Lord el 22 de Nov. de 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

Respuesta aceptada

Rik
Rik el 22 de Nov. de 2018
Editada: Rik el 22 de Nov. de 2018
somefunction=@(x) (abs(x)+x)/2;

Más respuestas (1)

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

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by