Given a large matrix of multiple eeg channels (signal_training), I have isolated one channel which is a 9000×1 array (Cz_channel). Another array is given and is also a 9000×1 array, filled with 1's 0's and 2's (StimulusSignal_training). 1 is produced when there is a flash of a non-stimulus and 2 when there is a flash of a stimulus. the 1's and 2's occur in groups of 24 samples. I am trying to group the occurance of each flash of non-stimulus in one matrix. so each column will be filled with the voltages from Cz_channel that correspond to each set of 24 1's. There are 150 flashes of non-stimulus. The code below is what i have written although, The matrix is not filling in the correct values and all the columns are the same? can anyone help it would be much appreciated!!

Cz_channel=signal_training(:,11); % extracting the EEG Channel from electrode Cz from the dataset of all 64 channels

Non_stim_index=find(StimulusSignal_training==1); % vector containing all the indices of CZ where non stimulus occurs

Stim_index=find(StimulusSignal_training==2); % vector containing all the indices of CZ where stimulus occurs

Non_stim=zeros(24,150);

n=0;

for m=1:150

for k=1:1:24

Non_stim(k,:)=Cz_channel(Non_stim_index(n+k));

end

n=n+24;

end

## Best Answer