Trouble Reading Multiple .csv Files. "Intermediate dot '.' indexing produced a comma-separated list..." Error.
Show older comments
Hello. I am trying to get Matlab to take 5 columns of data from multiple (6) .csv files, put the raw data in a structure, then read the raw data and seperate each column into it's own column in the same structure. When my 'for' loop tries to read the RawData to put it into seperate it into individual columns in the structure, I get a "Intermediate dot '.' indexing produced a comma-separated list with 2 values, but it must produce a single value to perform subsequent indexing operations." message.
1) What does this mean? I have searched what it is, but it's not clear to me.
2) Given my code (see below), does anyone know how to fix this issue?
Notes/Context: My first 4 rows of my csv files are headers (hence why I tell it to start reading data at row 5). Also, the length of data in each file is inconsistent (hence the 'ending' variable to read the hieght of the raw data in each csv).
Any advice would be greatly appreciated. Thank you for your time.
for i = 1:6
filename = uigetfile; %Select file
DataID(i).RawData = dlmread(filename,',', 4, 0); %Store raw data under "RawData" header in structure
ending = height(DataID(i).RawData); %Determine hieght of data
DataID(i).AxialStrain = DataID.RawData(1:ending,1); %Read first column of RawData and store data under 'AxialStrain' header in same structure
DataID(i).VolStrain = DataID.RawData(1:ending,2); %Read second column of RawData and store data under 'VolStrain' header in same structure
DataID(i).DeltaU = DataID.RawData(1:ending,3); %Read third column of RawData and store data under 'AxialStrain' header in same structure
DataID(i).p = DataID.RawData(1:ending,4); %Read fourth column of RawData and store data under 'AxialStrain' header in same structure
DataID(i).q = DataID.RawData(1:ending,5); %Read fifth column of RawData and store data under 'AxialStrain' header in same structure
end
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing 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!