I have arrays at the same size:
a = 5:10;
b = [1 0 1 1 0 0];
I want to select the element where in the boolean array (b) is 1.
c = [5 7 8];
I want to do it in elegant way without loop.
I have arrays at the same size:
a = 5:10;
b = [1 0 1 1 0 0];
I want to select the element where in the boolean array (b) is 1.
c = [5 7 8];
I want to do it in elegant way without loop.
You can just do c = a(logical(b))
if b is not already logical. If it is, then just c = a(b)
.