MATLAB: EEG plot without toolbox

digital signal processingeegplotting

I have my EEG data with 59 channels [(my_data is a 1619936×54 vector) ,fs=200] and a vector called markers (1×202) which have the events timepoints. How can i plot the events from one channel. I chose POz channel which is the 56 column of my data so:
chanPOz =my_data( :, 56);
plot(chanPOz(27900:28000),'b')
set(gca,'ylim',[0 100],'xlim',[0 50]);
The first element of markers is 27965 so i plot the channel between 27000 &28000 but obviously that is uncorrect

Best Answer

selection_idx = 27900:28000;
timevec = (selection_idx - 1) / fs; %the -1 is because time is assumed to start at 0
plot(timevec, chanPOz(selection_idx), 'b');
marker_to_idx = round(markers * fs) + 1; %the +1 is because time is assumed to start at 0
mask = ismember(marker_to_idx, selection_idx);
selected_markers_idx = marker_to_idx(mask);
selected_markers_time = markers(mask);
selected_markers_y = chanPOz(selected_markers_idx);
plot(selected_markers_time, selected_markers_y, 'r*'); %plot markers as red *
Related Question