0

我希望将大量 csv 文件导入 MATLAB。我可以毫无困难地做到这一点,除非它需要很多时间 - 每个文件大约 3 秒,使用以下代码。有没有办法更快地做到这一点?这A是一个 15 行 250 列的矩阵。有 150 个文件。

tic

file_name = [];
for w = scenario_size:-1:1
    file_name = sprintf('monthly_population_%d.csv',w) ; % read file name f
    A = xlsread(file_name);                
    pop(:,:,w) = A' ; 
end
clear A
toc
4

1 回答 1

1

You may have improved performance by using readmatrix, instead of xlsread. For example:

A = readmatrix(file_name);

Or, if you are on a Matlab release which doesn't have readmatrix, try readtable:

A = table2array(readtable(file_name));
于 2019-05-23T16:53:07.043 回答