MATLAB: Load .mat file from anyfolder

fileload

I have to load .mat file from a folder in my workspace. Can anyone tell me how to do so?

Best Answer

load C:\myFolder\mySubFolder\myMatFile.mat
or
variableName= 'myVarName';
matfilePath = 'C:\myFolder\mySubFolder\myMatFile.mat';
data = load(matfilePath);
% to access the variable
data.(variableName);
Related Question