Hoping this would result in some improvement by still keeping it with textscan
. Also, make sure the values look good.
Code
[filenames,filepath] = uigetfile('*.csv','Opening the data files',...
'','Multiselect','on');
filenames = fullfile(filepath,filenames);
NumFiles = numel(filenames);
PixelDouble = NaN(512*512,NumFiles);
for k = 1:NumFiles
fid = fopen(char(filenames(k)));
C = textscan(fid, '%d, %d, %d','HeaderLines',1);
PixelDouble(:,k) = C{3};
fclose(fid);
end
Pixel = num2cell(permute(reshape(PixelDouble,512,512,[]),[2 1 3]))
I must encourage you to follow this question - Fastest Matlab file reading? and it's answers.