is there any function that convert negative value to zero?

조회 수: 45 (최근 30일)
Jinsu Kim
Jinsu Kim 2018년 11월 22일
답변: Steven Lord 2018년 11월 22일
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에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by