I have an EEG data base that I would like to plot. The database is a 19*1000*134 matrix, with:
- 19 being the number of channel. On a first approach, I'm working with only one channel.
- 1000 the size of a sample (1000 points for a sampling rate of 500 Hz, i.e. 2 sec of data)
- 134 the number of epochs (number of different 2 second experience)
The idea is to plot epoch n right after epoch n-1 on the same graph. The (X,Y) matrix used to plot this has a 134 000 * not_much size, and I would like to be able to scroll horizontally on the plot, to see individually each epoch.
My code right now, plotting only one channel:
fs = s_EEG.sampling_rate;
[channel, length, nb_epoch] = size(s_EEG.data)
display(s_EEG.data, fs, length, channel, nb_epoch)
function display(data, fs, length, channel, nb_epoch)
figure("Name", "Epoch display")
for j = 1:nb_epoch
time = 0.002+(2*j-2):1/fs:2*j;
epoch = data(1,:,j);
plot(time, epoch)
hold on
end
hold off
end
I'm completely new to Matlab, and I don't use it well yet, but I would like to find a way to see on the same graph, individually, and at a correct visualization scale, all of my 134 epochs (one color = one epoch above).
Thanks !
This is very similar to something I already had so I tweaked it a bit for you. Basically pass plotData your
data
matrix. It will plot each of your items sequentially as you already have now.Pressing the slider will change your x-limits so that you will step through 1 element (epochs) at a time. Clicking in the area will advance 2-epochs at a time. It currently just displays what you currently viewed "epoch" # is at the command line
disp(['Current Epoch: ' num2str(viewI)])
However, it should be easy for you to redirect that to a text box on the figure to more readily know which you are viewing ... besides mentally dividing the x-limits by 2.Use the list box to switch to a new channel which will reset the plot & x-limits.
Call it like this at the command line.
CODE: Save everything below as plotData.m
Note: This uses implicit expansion so you need Matlab 2016b or higher.