Read multiple excel files in matlab and combine them in one file
2 次查看(过去 30 天)
显示 更早的评论
I have two different folders "a" and "b", both containing a series of excel files let's say (a1, a2, a3...) and (b1, b2, b3...). I would like to write a matlab code that reads all the excel files in the two folders consecutively and merge them in one excel file (a1+b1,a2+b2,a3+b3...) with two separate spreadsheet (spreadsheet 1 contains the data from the "a" file and spreadsheet 2 contains the data from "b" file). Any idea on how to do that?
I know I can use xlsread and xlswrite to import and export data, but I have no idea how to tell matlab to read files from two different folders and to merge them in one single file with two spreadsheet.
0 个评论
回答(1 个)
dpb
2015-10-12
Nothing particular to it; simply read the two file sequences into separate variables and merge those as desired. It isn't clear what you actually are wanting; you talk of "two spreadsheets" in a single file but show some N combinations. That's pretty much immaterial other than keeping indices to what it is you do need at the same time or whether you're simply trying to copy all single files now into one.
Basically, all you need to know is covered in the FAQ How can I process a sequence of files? with the addition of simply using similar techniques as demonstrated there to dynamically creating file names to do similar for worksheet names.
I'd strongly suggest in this case given the type of file names you mention using the dir solution w/ appropriate wild card names to get the two groups of existing files...
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!