| Logical Indexing with a Smaller Array In most cases, the logical indexing array should have the same number of elements as the array being indexed into, but this is not a requirement. The indexing array may have smaller (but not larger) dimensions: A= [12 3;4 5 6;7 8 9] A = 12 3 4 5 6 7 8 9 B = logical([0 1 0; 1 0 1]) B = 0 10 10 1 isequal(numel(A), numel(B)) ans = 0 A(B) ans = 4 7 8 MATLAB treats the missing elements of the indexing array as if they were present and set to zero, as in array C below: % Add zeros to indexing array C to give it the same number of % elements as A. C = logical([B(:);0;0;0]); isequal(numel(A), numel(C)) ans = 1 A(C) ans = |