is there any function that convert negative value to zero?

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일

0 개 추천

Use the max function with two inputs.

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2018년 11월 22일

답변:

2018년 11월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by