Illustration of Logical vectors:
Calling the function appears to return similar vector as simply vec > 5, and summing the result still works to determine how many elements were greater than 5.
>> notlog = testvecgtn(vec,5)
notlog =
0 1 0 0 1 1
>> sum(notlog)
ans =
3
Though, as before, it could not be used to index a vector as the elements are double, and not logical:
>> vec(notlog)
??? Subscript indices should either be real positive integers or logical.