Info
此问题已关闭。 请重新打开它进行编辑或回答。
Summing data from different excel files
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a problem where I want to sum numerical values from various excel files in a subfolder. I have imported the data to Matlab in table format. Let's sat I have 10 different excel files, with 20 rows and 2 columns, from where I want to sum the values from column 1 to a new file, e.g. excel or directly in the matlab. This is my code:
for fol_no=1:numel(subfolderNames) fileInfo = dir(subfolderNames{fol_no}); fileNames = {fileInfo.name}; fileNames(ismember(fileNames,{'.','..'}))=[]; fol_no for file_no = 1:numel(fileNames) fileNames
ImportedData{fol_no,file_no} = readtable(char(fullfile(fileInfo(1).folder,fileNames(file_no))));
el=table2array(ImportedData{fol_no,file_no}(:,[1 7]));
%tar ut månadsdata
ind1=el(:,1)==1;
el1=el(ind1,:)
%summerar inom varje excel-fil
eltot=sum(el1(:,2))
%extraherar data som jag är intresserad av, dvs månadsbasis för samtliga
%byggnader
ImportedData_2{fol_no,file_no} = el1
ImportedData_3{fol_no,file_no} = eltot end end total = table(ImportedData_2,'RowNames',subfolderNames)
total2 = table(ImportedData_3,'RowNames',subfolderNames)
Is it better for me to perform this with the loop? Or during the post process work.
Thanks! :)
0 个评论
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!