Hi all,
I wrote below MATLAB code to import multiple csv files named B00Pr1-0001 to B00Pr1-n in a folder and save them in a cell:
l=dir('B00Pr1-*.csv'); % list .csv files
n=length(l); data=cell(1,n); for i=1:n data(i)=csvread(l(i).name);end
The problem is that my csv files look like below (its actual size is bigger) and have strings in the first row so I cannot use csvread because I get the following error:
Error using dlmread (line 147)
Mismatch between file and format character vector.
Trouble reading 'Numeric' field from file (row number 1, field number 1) ==>
nodenumber, x-coordinate, y-coordinate,velocity-magnitude, x-velocity,
y-velocity, temperature\n
nodenumber x-coordinate y-coordinate velocity-magnitude x-velocity y-velocity temperature1 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 9.98E+012 1.25E-04 0.00E+00 0.00E+00 0.00E+00 0.00E+00 9.93E+013 2.50E-04 0.00E+00 0.00E+00 0.00E+00 0.00E+00 9.87E+014 3.75E-04 0.00E+00 0.00E+00 0.00E+00 0.00E+00 9.80E+015 5.00E-04 0.00E+00 0.00E+00 0.00E+00 0.00E+00 9.74E+016 6.25E-04 0.00E+00 0.00E+00 0.00E+00 0.00E+00 9.67E+017 7.50E-04 0.00E+00 0.00E+00 0.00E+00 0.00E+00 9.60E+018 8.75E-04 0.00E+00 0.00E+00 0.00E+00 0.00E+00 9.54E+019 1.00E-03 0.00E+00 0.00E+00 0.00E+00 0.00E+00 9.47E+0110 1.12E-03 0.00E+00 0.00E+00 0.00E+00 0.00E+00 9.40E+0111 1.25E-03 0.00E+00 0.00E+00 0.00E+00 0.00E+00 9.34E+0112 1.37E-03 0.00E+00 0.00E+00 0.00E+00 0.00E+00 9.27E+0113 1.50E-03 0.00E+00 0.00E+00 0.00E+00 0.00E+00 9.21E+01
my goal is loading all csv files data do some math on the data and save them in a matrix. What do you suggest to solve this problem?
thank you in adavance!
Best Answer