MATLAB: Does this code generate an error

MATLAB

Hi all,
The below code is generating an error :
The code used here is:
%BATCH MODE
files = dir('C:\Users\Deakin Uni\Documents\MATLAB\a');
fNames = {files.name};
%for each file
for k= 1: length(fNames)
% extract file name
fName = ['C:\Users\Deakin Uni\Documents\MATLAB\MAX', fNames{k}];
[XDATA, TIMESTEPS] = importfile(fName);
a1 = XDATA - mean (XDATA);
plot(TIMESTEPS, a1);
[peakvals,peaklocs] = findpeaks(a1, 'minpeakdistance',50, 'minpeakheight', 0.00001);
peaktime = TIMESTEPS(peaklocs);
createfigure4(TIMESTEPS, a1, peaktime, peakvals)
saveas(gcf, 'chaitu.fig')
end
The error here is: Error using xlsread (line 132) XLSREAD unable to open file 'fName'. File 'fName' not found.
Error in importfile (line 36) data = xlsread(workbookFile, sheetName, sprintf('A%d:B%d',startRow(1),endRow(1)));
Thanks in advance

Best Answer

Presumably, the cause is that for some value of k,
['C:\Users\Deakin Uni\Documents\MATLAB\MAX', fNames{k}]
does not resolve to a string that corresponds to a file name in that directory.
I suggest you display the name of each file as you try to access it, and that should lead you to the specific file name that is problematic.