reading Excel data from Matlab, slow process
Show older comments
Hi everyone,
Got a question...
I have my data stored as Excel files, I use 'xlread' command to read them, calculate the average, and then write the results again on the same Excel files. I have about 3000 files and each file has 1000 samples. These are the codes for my programme:
clc
clear d
clear all
format long
a=0;
b=0;
c=0;
h=1;
d = zeros(1000, 1);
for count=1:2632
if a==45
a=0;
b=b+1;
end
for cell=11:1010
format bank
d(h,1)=xlsread(['D:\S9_G24' '\X' num2str(a) 'Y'
num2str(b) 'Z' num2str(c) '.xls'],1,['B' num2str(cell)]);
h=h+1;
if h==1001
aver=mean2(d);
xlswrite(['D:\S9_G24' '\X' num2str(a) 'Y'
num2str(b) 'Z' num2str(c) '.xls'],aver,1,'B1012');
a=a+1;
h=1;
end
end
end
Codes are fine, but the time it takes is extremely long. It is killing me as I am a bit in rush to get these results. Should I convert my data to a special format or something? I was wondering if anyone has got a good suggestion to speed up the process. I appreciate your help.
BW,
S:-)
1 Comment
Jan
on 17 Nov 2011
Please do not post a question twice.
Accepted Answer
More Answers (1)
Steven
on 18 Nov 2011
1 vote
To get around the fact that the xlsread & xlswrite commands are very slow you'll need to use ActiveX commands. They aren't complicated at all and are explained very clearly on the following website: http://www.orient-lodge.com/node/3430
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!