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 日

0 投票

somefunction=@(x) (abs(x)+x)/2;

その他の回答 (1 件)

Steven Lord
Steven Lord 2018 年 11 月 22 日

0 投票

Use the max function with two inputs.

カテゴリ

ヘルプ センター および File ExchangeData 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