Since you are looking for which channels were hit across all stretchers for all events, then you will need two for loops for the looping of the data, and an additional inner for loop to iterate over the 32 channels. Something like
[m,n] = size(a);
for event=1:m
for stretcher=1:n
end
end
If you are only interested in those stretchers from some event that has a hit channel, then you can exclude all the 0's (since no hits on any channel) and the "do stuff" from above becomes
val = a(event,stretcher);
if val~=0
bitMask = 1;
channelsHit = cast(zeros(1,32),'uint8');
atHit = 0;
for k=1:32
if bitand(val,bitMask)
atHit = atHit+1;
channelsHit(atHit) = k;
end
bitMask=bitshift(bitMask,1);
end
channelsHit = channelsHit(1:atHit);
end
Once you have your list of hit channels for the (event, stretcher) pair, you can save those three pieces of information to a cell array for later analysis.
Best Answer