This question is closed. Reopen it to edit or answer.

Summing data from different excel files

1 view (last 30 days)
Vlatko Milic
Vlatko Milic on 15 Jan 2018
Closed: MATLAB Answer Bot on 20 Aug 2021
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 = {}; 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
%summerar inom varje excel-fil
%extraherar data som jag är intresserad av, dvs månadsbasis för samtliga
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! :)

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by