I am trying to run a loop over multiple files, by feeding the file names into a function. I have saved these file names as a structure using:
files=dir('testdata\*.siz');
nrows=size(files,1);
Now my loop is:
for i=1:nrows
filename=files.name{i};
Singapore(filename);
writetable(ans,'file.xls')
end
However, I get the error:
"Field reference for multiple structure elements that is followed by more reference blocks is an error."
I found that the error is in
filename=files.name{1};
but everywhere I've searched tells me to use { } to access fields in a structure. I also have tried other types of brackets in vain.
Additional Information:
'files' is the name of the structure
'name' is the first column field within 'files' containing the file names in inverted commas.