I exported data from excel into a table, how do I sum the values of each column from that table excluding NaN's
2 views (last 30 days)
Show older comments
T = readtable('Inventory.xlsx')
%now I need to sum each column, for example the data in column 2 is for Copper
0 Comments
Answers (1)
Star Strider
on 20 May 2022
Two options —
T = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1005700/Inventory.xlsx')
S1 = nansum(T{:,2:end})
S2 = sum(T{:,2:end},'omitnan')
Both give the same result.
.
2 Comments
Star Strider
on 20 May 2022
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!