Boolean Indexing

You can’t index a vector with a single Bool, it needs to be a vector of bools, see the docs here:

https://docs.julialang.org/en/v1/manual/arrays/#Logical-indexing

Are you maybe looking for

res = ifelse.(test .> 5, 5, 0)

?

3 Likes