MATLAB: How to import CSV files using csvread

csvcsvreadfilesimport

I cannot seem to import the multiple CSV files the code I am using is below:
%% Import data
numfiles = 54; % number of CSV files mydata=cell(numfiles,1); % defining size of mydata
for i=7:length(mydata) % loop to import mutliple CSV files
myfilename = sprintf('Trial%d.csv', i); % define file name
mydata{i} = csvread(myfilename); % import files into mydata
end

Best Answer

Looks like should work presuming your filenames are ok but I'd do it slightly differently.
Try sotoo...
d=dir('*.csv'); % return the list of csv files
for i=1:length(d)
m{i}=csvread(d(i).name); % put into cell array
end
Worked here for a few in my working directory.
Note that the files need to be consistent with what content csvread can handle which is numeric array data only.
What specific problem did you encounter?
Related Question