Creating a function that goes through a Matrix and scans for any values lesser than 0 (so -1 for example) ?

1 次查看(过去 30 天)
I need help with creating a function that goes through a Matrix and scans for any values lesser than 0 (so -1 for example) and then replaces it with a 0 if it is less than 0 but does not change any other value that is equal to zero or greater than zero and finally returns back the original input matrix with the less than 0 numbers converted to zero.

采纳的回答

ME
ME 2019-11-5
编辑:ME 2019-11-5
For a matrix A
A(A<0)=0
will convert all negative values to zeros.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by