Make a sript faster

1 view (last 30 days)
Leeee
Leeee on 16 Apr 2019
Commented: Leeee on 17 Apr 2019
Hello everyone,
Does anyone know how to make this script faster knowing that I have 800 matrix to import?
pathname = uigetdir();
cycle = cell(2,400);
for i = 1:2
for j = 1:100
for k = 1:4
filename = sprintf('Cycle%d_Image%d_%d.csv', j, k, i);
if exist(fullfile(pathname, filename), 'file')~=2
error('File not found: %s', fullfile(pathname, filename))
end
strrepInFile(fullfile(pathname, filename), ',', '.');
cycle{i,4*(j-1)+k} = dlmread(fullfile(pathname, ['new_' filename]), ';');
delete(fullfile(pathname, ['new_' filename]))
end
end
end
  7 Comments
Walter Roberson
Walter Roberson on 16 Apr 2019
dlmread calls textscan. You can avoid some overhead by calling textscan yourself especially if the files have fixed format.
Leeee
Leeee on 17 Apr 2019
@John and @Walter,
Thank you for your answers I admit that it is super effective your contributions I am delighted. Thanks again!

Sign in to comment.

Answers (0)

Categories

Find more on File Operations in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!