Indexing several Data files to extract a column from each file

Hello,
I have 10000 different *.xls files. I have imported them to my workspace and would like to extract only column 3 from each of the 10000 files. Each file has 10 columns.
Having extracted the 3rd column from each file, I would like to preallocate a matrix where the 10000 columns would be stored as my output file.
Assume that my file has length(15000) as it contains daily precipitation timeseries for a long period.
I appreciate your response.
Zilefac.

댓글 수: 3

Additionally, the 10000 files have a common extension .xls and different names. However, the names are numerical and increase sequentially by a factor of 1 e.g 001.xls, 002.xls etc.
Clarify what "length(15000)" means. Is it the number of rows in the desired output?
Hello Matt,
length(15000) is the number of rows in the input file.

댓글을 달려면 로그인하십시오.

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2012년 10월 18일
편집: Azzi Abdelmalek 2012년 10월 18일
A=zeros(15000,1000);
for k=1:1000
filename=sprintf('file%d.xls',k)
num=xlsread(filename)
A(:,k)=num(:,2)
end

추가 답변 (1개)

Sachin Ganjare
Sachin Ganjare 2012년 10월 18일

0 개 추천

With xlsread command you can read partcular column in xls file.
Below link will be useful in this regard:
Hope it helps!!!

카테고리

도움말 센터File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by