Single quotes and double quotes make two different kinds of text.
Text in single quotes is a character vector, class char: a row of characters, one per letter. 'sub-01' is 1 row by 6 characters, and you can index single characters just like numbers in an array.
subj = 'sub-01' class(subj) size(subj) subj(1:3) subj(end)
Text in double quotes is a string, class string. A string holds the whole piece of text as one value, so its size is 1-by-1. strlength counts its characters.
s = "sub-01" class(s) size(s) strlength(s)
Strings arrived in newer versions of MATLAB. EEGLAB is written around character vectors, so use single quotes for file names and options you pass to EEGLAB.
Character vectors join with square brackets, the same way arrays do. Strings join with +.
['sub-' '02' '.set'] "sub-" + "02" + ".set"
To put a number into a file name, turn it into text first. num2str does that. sprintf fills a template: %d is a whole number, %02d pads it to two digits, %s is text, and %.1f is a number with one decimal.
n = 3;
['sub-0' num2str(n) '.set']
sprintf('sub-%02d.set', n)
sprintf('sub-%02d.set', 12)
sprintf('%s filtered at %.1f Hz', 'sub-03', 0.1)
With %02d, participant 3 becomes sub-03 and participant 12 becomes sub-12, so one template covers everyone. Lesson 8 uses this in a loop.
Adding a number to a character vector does not join them. MATLAB turns each character into its character code and adds to that. And == compares text one character at a time, so it fails when the lengths differ. Use strcmp to ask whether two pieces of text are the same.
'sub-' + 1 # four numbers, not 'sub-1' strcmp(subj, 'sub-01') subj == 'sub-1'
pop_loadset('filename', 'sub-01.set', 'filepath', 'data') is four pieces of text. The first and third name an option and the second and fourth give its value. Inside the dataset, the set name, the channel labels, and the event codes are character vectors too.Each box ticks itself when you do it in the practice window. Stuck? "show me" puts a command in the window for you.
The MathWorks, Inc. (2025). MATLAB documentation. https://www.mathworks.com/help/matlab/