To find the index of 1s in a logical array in MATLAB, you can use the find function. The find function returns the linear indices of the nonzero elements in the input array. For a logical array, the nonzero elements are those that are true, which corresponds to the value of 1.
Here's an example:
main.m123 chars6 lines
The variable idx will be a column vector containing the linear indices of the elements that are true in the logical array A. You can use the ind2sub function to convert these linear indices to subscript indices if needed.
gistlibby LogSnag