Q:

How does logical indexing work?

In some high-level languages like Matlab, you can use "logical indexing" to select a whole set of entries in an array for operating on.
I understand what logical indexing is and how to use it.
Instead, I am asking:

How does it work ("behind the scenes")?
Does it not boil down to just a for-loop?
If so, why is it so much faster than for-looping?

A:

Interpreted languages can be thought of as a variation on assembler running on an emulated core.  They have stacks and commands that work in ways like the assembler without actually being the assembler.  They are a virtual machine.
A for loop can be thought of as telling the system, set a value, run a sequence of tasks, and when you are done then come back and check on that value.  If it is not at a threshold, then change it in a prescribed way, and go repeat those tasks and come back.  In assembler you are running screaming fast, but in the "VM" not so much.  Consider the demonstration between 13:50 and 15:30 of this link: (link)
This means that what appears to be a for loop, isn't actually a for loop.  It is operating system interrupts, and virtualized memory.  It is virus-scans in the background and megasloth bloatware.  
If you had a virtual system, could you make a short-cut for addressing memory that didn't use the virtualized for loop, that was reasonably efficient?  MatLab tries to major on data processing, so it has to have very efficient ways of storing, sorting, and selecting data within its virtual machine.
MathWorks is not going to make the details of this accessible to the public.  If it has a great idea then they don't want it implemented in Python, and R tomorrow.  If it has a mediocre idea then they don't want to be beaten in execution by Python and R tomorrow.  Either way, making the nuts and bolts of that particular approach accessible to the public without an NDA - it is likely a losing proposition for them.  
Bottom lines:

its not a real "for", even for a for loop, because its running virtually
they are opening up some of the internals of their data handling to improve usability
they aren't likely to disclose actual code because of negative business consequences

It is worthy to note that vectorized code can outperform for loops while doing the same thing.  This means they likely are applying more of that internals to execution of the "sequence of tasks" to get performance improvement.

