Hi everyone,
I need to open a large number of CSV files. The files are indexed according to some variables "ENF" (that goes from i=1:I) and "Theta" (that goes from j=1:J). Each file contains a large number of rows and columns. The number of columns and rows differ across files.
I would like load the data into a structure like this:
dataStruct.(ENFi).(Thetaj) = FileName_i_j.csv
This is my code to load the data:
I = 50; J = 100; DirData = ('/Users/MyDir');NameData1 = ('Name1');NameData2 = ('Name2');for i=1:I % I would like to parallel process this
fprintf('ENF: %4.0f \n', i) for j=1:J FileName = [DirData NameData1 num2str(i) NameData2 num2str(j)]; Dat1 = ['ENF' num2str(i)]; Dat2 = ['Theta' num2str(j)]; dataStruct.(Dat1).(Dat2) = csvread([FileName '.csv']); endend
This loop takes a while. I would like to parallel process the first "for". I thought it should be straightforward. However, I cannot figure out how to do it. Matlab complains about the data structure within the parfor.
Any suggestions or ideas?
Thanks. Javier
Best Answer