Problem with 'xlsread', incomplete data imported when using loop
5 views (last 30 days)
Show older comments
Hi, I am facing problem with reading excel data to matlab. I tried using 'xlsread' and 'importdata' but facing the same problem. I am trying to read various excel files using loops, and the imported excel data is incomplete, some of my data has 76 rows but it read only 12 rows. But when I run only the excel file that shows wrong number of row, I can get complete and correct number of rows. My code is like this:
rr=[];
for subject=1:2
for task=1:2
for record=1:3
fileNames=sprinf('s%d_t%d_r%d',subject,task,record)
a=xlsread([fileNames '.xlsx'],1);
[r,~]=size(a);
rr=[rr;r];
end
end
end
The 'rr' returns these values:

but the actual number of rows for 7th, 8th and 9th were wrong, only 12 rows were read from these files, they were actually 76, 67, 77, respectively. This is not the first time I encounter this problem, previously only few files and I can run them separately. Now I need to gather data from different files for use. Is there any way to solve this problem?
0 Comments
Answers (0)
See Also
Categories
Find more on Spreadsheets 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!