MATLAB Answers

Fill a matrix using a for loop

16 views (last 30 days)
Rn on 3 Jan 2021
Commented: Rn on 4 Jan 2021
Given a large matrix of multiple eeg channels (signal_training), I have isolated one channel which is a 9000x1 array (Cz_channel). Another array is given and is also a 9000x1 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
for m=1:150
for k=1:1:24


Sign in to comment.

Accepted Answer

VBBV on 4 Jan 2021
Use for loop index to store different values

  1 Comment

Rn on 4 Jan 2021
That worked, Thank you!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by