What does a(a<0) = 0 mean in matlab?
14 views (last 30 days)
Cris LaPierre on 23 Jun 2022
Yes, it works on arrays. It is using logical indexing to assign values to a. You can learn more about logical indexing in Ch 11 of MATLAB Onramp.
Basically, set any value in a that is less than zero to zero. Here's a simple example.
a = rand(3)