Yes, you will receive this error whenever your dir doesn't find any file. Three things:
- Use meaningful variable names, dircontent is a lot better variable name than a.
- don't build paths by string concatenation. Use fullfile instead:
dircontent = dir(fullfile(myDir, ext_img);
- Never use max(size(vector)) to get the number of elements in a vector. When dir doesn't find any file, it returns a 0x1 vector. max of 0 and 1 is 1, even though the vector has 0 elements. Always use numel to get the number of elements. It's faster, shorter and always works.
myDir = 'C:\Users\bpeoples\Downloads\SCANSNAPCODE_BDP\Numerical Comparison\Diffused Above, SV600 Raised\1st 25';
ext_img = '*.jpg';
dircontent = dir(fullfile(myDir, ext_img));
assert(numel(dircontent) > 0, 'No file was found. Check that the path is correct');
my_img = struct('img', cell(size(dircontent)));
for fileidx = 1:numel(dircontent)
my_img(fileidx).img = imread(fullfile(myDir, dircontent(fileidx).name));
Of course, you still need to fix the initial problem which is that dir didn't find any file. Most likely, you've made a mistake with your path.