is there any function that convert negative value to zero?

46 ビュー (過去 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 件のコメント
Jinsu Kim
Jinsu Kim 2018 年 11 月 22 日
It really simple !! Thanks

サインインしてコメントする。

その他の回答 (1 件)

Steven Lord
Steven Lord 2018 年 11 月 22 日
Use the max function with two inputs.

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by