MATLAB looks for files in the current folder first, then along the path.
pwd ("print working directory") shows the current folder, the same one named at the top of the Current Folder panel. ls lists what is inside it.
pwd ls
cd ("change directory") moves into a folder. cd .. goes up one level. Double-clicking a folder in the Current Folder panel does the same thing.
cd psych390 ls cd data ls cd .. pwd
cd data is a relative path: it starts from wherever you are. A full path starts from the top of the disk and works from anywhere. On a Mac it starts with /Users/; on Windows it starts with a drive letter, like C:\Users\.
cd /Users/student/Documents/MATLAB/psych390
A file name without a full path is looked up in the current folder. The same command can find a file from one folder and miss it from another.
isfile('data/sub-01.set')
cd ..
isfile('data/sub-01.set')
cd psych390
fullfile joins folder and file names with the right separator for the computer, which keeps a script working on both Mac and Windows.
fullfile('data', 'sub-01.set')
Functions are files too: mean is a file called mean.m. When you type a name, MATLAB checks the current folder, then each folder on its search path in order (the Path panel). MATLAB's own functions are always on the path. EEGLAB's are not until you add them.
which mean which eeglab eeglab
addpath adds a folder to the path. Give it the full path to the EEGLAB folder you downloaded; the version number in the name will match your download. Then run eeglab, and it adds its own subfolders. Watch the Path panel as you go.
addpath('/Users/student/Documents/MATLAB/eeglab2025.1')
which eeglab
which pop_loadset
eeglab
which pop_loadset
pop_loadset lives in a subfolder (functions/popfunc), so MATLAB could not find it until eeglab ran and added that subfolder.
eeglab add the rest itself.MATLAB forgets addpath changes when it quits. savepath (or Save in the Set Path window, opened with pathtool) keeps them for next time. On a shared lab computer you may not be allowed to save the path. Then put the addpath line at the top of your script instead.
savepath
addpath. A file-not-found error from pop_loadset means MATLAB is looking in the wrong folder; fix it with cd or a full 'filepath'.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/
EEGLAB Wiki. (n.d.). Installing EEGLAB. https://eeglab.org/tutorials/01_Install/Install.html
Luck, S. J. (2022). Applied event-related potential data analysis. LibreTexts. https://doi.org/10.18115/D5QG92