I am not a very frequent Matlab user. So today, when I got the message "Subscript indices must either be real positive integers or logicals."
it got me wondering. What would happen if I did
x = [1 2 3];
x(true)
x(false)
My guess would have been that false is treated as 0 and true as 1, so the x(true)
should have returned the first element, which it did, while x(false)
should have returned an error. It didn't. x(false)
apparently returns an empty array. Why?
I couldn't find any reference about this rather odd behaviour, that's why I'm asking here, sorry if it's a duplicate or some normal behaviour I should know about.