Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create inverse logical array in Matlab

Tags:

matlab

I have a logical array, isLand, that is true if the index is over land and false if the index is not over land, like the ocean. How can I easily create another logical array, isOcean, which is the inverse of isLand. All the ones in isLand will be zeros in isOcean and vice versa.

I know I can do this using a for loop but I feel there is a much better way.

like image 656
Elpezmuerto Avatar asked Oct 16 '25 07:10

Elpezmuerto


1 Answers

Just use the logical NOT operator:

isOcean = ~isLand;

Easy-peasy lemon squeezy! ;)

like image 77
gnovice Avatar answered Oct 19 '25 00:10

gnovice



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!