I'm assuming you want to pass a filename to your specific_m_routine
function? If so, you need to use dir
and files(k).name
rather than listing all of your files in a cell array and referring to them with files{k}
.
files = dir('*.asc');
ratios = nan(1, numel(files));
for k = 1:numel(files)
ratios(k) = specific_m_routine(files(k).name);
end
Or if you want to be able to use any directory.
folder = fullfile('path', 'to', 'data');
files = dir(fullfile(folder, '*.asc'));
ratios = nan(1, numel(files));
for k = 1:numel(files)
ratios(k) = specific_m_routine(fullfile(folder, files(k).name));
end
This way will not require the files you're trying to load to be in the current directory.
As a side note, I feel like you have asked some variant of this exact question the past few days but haven't taken the time to digest the answers you have gotten. Please go back and review all of them to get a better idea of what you're trying to do.