MATLAB: When I run the following code it only shows the last file in the directory in MATLAB workspace? How to get all the files in the directory saved in the workspace

ivsFiles = dir('*.ivs');
numfiles = length(ivsFiles);
for k = 1:103;
filename = ivsFiles(k).name;
fileID = filename;
C = textscan(filename,'%d');
end

Best Answer

ivsFiles = dir('*.ivs');
numfiles = length(ivsFiles);
C = cell(numfiles,1) ; % initialize each file's data into a cell
for k = 1:numfiles;
filename = ivsFiles(k).name;
fileID = filename;
C{i} = textscan(filename,'%d');
end
Please note that, you will eat up the memory if the files are huge.