Simply EEGLAB

MATLAB basics for EEGLAB

Station 0 · Lesson 3 · EEGLAB 2026.1

In the GUI

  1. Command WindowWorkspaceCurrent Folder
  2. New ScriptHome
  3. RunEditor .mdemo_basics

Script

demo.srate  = 128;                              % sampling rate (samples per second)
demo.nbchan = 3;                                % number of channels
demo.pnts   = 10 * demo.srate;                  % samples per channel
demo.labels = {'Fz', 'Cz', 'Pz'};               % channel names (a cell array of text)
demo.data   = randn(demo.nbchan, demo.pnts);    % random numbers, channels x samples
size(demo.data)                                 % rows = channels, columns = samples
demo.srate                                      % one field
demo.labels{2}                                  % text of the second channel name
firstSamples = demo.data(2, 1:5)
t = (0:demo.pnts-1) / demo.srate;
t(end)
figure;
plot(t, demo.data(2, :));
xlabel('Time (s)'); ylabel('Amplitude');
title(['Channel ' demo.labels{2}]);
whos demo                                       % size and type of a variable
which plot                                      % location of a function on the path

Which value should I choose?

You typeMeaningExample from the lessons
a = 5Create a variable and print its valuex = 5
a = 5;Same, without printingEEG = pop_eegfiltnew(EEG, 'locutoff', 0.1);
s.nameA field inside a structEEG.srate
m(2, 1:5)Elements of a matrix, with round bracketsEEG.data(1, 1:10)
c{2}Contents of a cell array element, with curly bracesdemo.labels{2}
'text'Text in single quotes'locutoff'
%Everything after it on the line is a comment and is not run% high-pass
help nameHelp for a function in the Command Windowhelp pop_eegfiltnew

Full lesson: https://simplyeeglab.pages.dev/en/lesson/matlab-basics/

Content license: CC BY-NC-SA 4.0 · MIT (code)

An independent learning site, not affiliated with EEGLAB or SCCN.