How to write this Boolean operator?

Y is latitude and I want those that are falling within -90 and 90 degrees.

Indx = Y .> -90 .& Y.< 90;

I tried &, &&, .&. All of them gave me headaches. What should be the correct way of expressing this in Julia?


I think you need some parentheses:

Indx = (Y .> -90) .& (Y.< 90);

Many thanks! Yes, with the parenthesis, it has been working.

If you find it more convenient, Julia permits comparisons in this form as well:
Indx = -90 .< Y .< 90


Wow, it’s great to learn something even simpler. Many thanks for sharing :+1:

Although, if you have latitudes that are smaller than -90 or larger than 90 there may be something wrong, no? (unless you selected another range of length 180 for the latitudes but then that would also need some transformations to all the latitudes.

Thanks for the reply.

That’s true. All the latitudes should be between -90 and 90. Here, I just want my indx to include all. I use indx to get the values from some predefined latitude bands. To be consistent, I use the above argument for the global coverage. Or is there a better way to do this?