MATLAB: How to load a .mat file from the parent directory

directoryloadrun

How to load a file which is in the parent directory of the running script?

Best Answer

you can determine your current directory with pwd.
so to load the file it'll go something like this
myfile = 'mymatfile.mat';
[parentdir,~,~]=fileparts(pwd);
load(fullfile(parentdir,myfile))