% all stimuli onsets (use 1 + to cope for the fact that the % first value in diff rather codes the second sample in the data! all_onsets = 1 + find(diff(gsr.ChannelData(8)) > 0); % now split into three conditions neu = 0.01 * all_onsets(gsr.ChannelData(2, all_onsets) > 0); neg = 0.01 * all_onsets(gsr.ChannelData(3, all_onsets) > 0); rea = 0.01 * all_onsets(gsr.ChannelData(4, all_onsets) > 0);