How to get consistent import data outputs
Show older comments
Im my program I am attempting to import multiple xcel files in a for loop. Then storing the results in a struct with dynamically named fields which I can evaluate later. However, when the for loop is done I get what is in the screenshot below the code.
for i=1:sizeOfSel
j = num2str(i);
fieldName = strcat('data_' , j);
stmfile = temp(i,:)
pathname = handles.A.dir;
tic
handles.A.data.(fieldName) = importdata(fullfile(pathname, stmfile));
toc
end

Ideally, I need every field to contain a structure that import data is outputting. But because only one or two of the files being processed actually fit the format, I can only process those files. The image shows the output of two identical xcel files.
Accepted Answer
More Answers (1)
Walter Roberson
on 29 Jun 2015
1 vote
Are they really identical, or have some of them been saved in csv (Comma Separated Value) format, and some of them in binary format (.xls)? And possibly some of them are in .xlsx structured text format?
You will probably need to switch to xlsread() instead of importdata()
Categories
Find more on Workspace Variables and MAT Files in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!