MATLAB: Want to load mat files one by one from specified folder.. But not able to do that…

load multiple mat files

Want to load mat files one by one from specified folder.. and want to perform further operations on it..
Mat file contains a single image array data..
Following code gives error.. but that mat file is present to specified location
Code:
myFolder = 'H:\Try\module\ref';
filePattern = fullfile(myFolder, '*.mat');
matFiles = dir(filePattern);
for i = 1:length(matFiles)
baseFileName = matFiles(i).name;
load(baseFileName);
end
Output:
Error using load
Unable to read file 'abc.mat'. No such file or directory.

Best Answer

baseFileName = fullfile(myFolder, matFiles(i).name);