Reading in xls files from folder- saving data with identifier from filename
2 ビュー (過去 30 日間)
古いコメントを表示
Hi, I have a folder full of xls files, named data_00001 through data_10000. Each file has a dozen or so identically named tabs full of RV's. I am interested in reading all files and tabs and creating histograms of the RV's.
Is there a way to read in the last 5 digits of the file names and attached them to each tab name (which I saved as a variable) ? Then each variable is a n*1 cell array, where each cell contains the raw RV data?
I used regexp to extract the number as a string and converted it to a double, and I used a for loop to save variable X {1,k} via importdata. How can I incorporate the saved double into this variable?
0 件のコメント
回答 (1 件)
Cedric
2013 年 11 月 1 日
編集済み: Cedric
2013 年 11 月 5 日
You can build a solution based on the following (not tested).
D = dir( 'Z:\MyFiles\FileName\d*.xls' ) ;
tabs = {'X', 'Y', 'Z'} ;
nFiles = length( D ) ;
nTabs = length( tabs ) ;
data = cell( nFiles, nTabs ) ;
for fId = 1 : nFiles
for tId = 1 : nTabs
idStr = D(fId).name(6:10) ;
data{fId,tId} = xlsread( D(fId).name, tabs{tId} ) ;
end
end
Let me know if your setup is different (in particular for tab names), and I can adapt the answer.
2 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!