I exported data from excel into a table, how do I sum the values of each column from that table excluding NaN's
5 次查看(过去 30 天)
显示 更早的评论
T = readtable('Inventory.xlsx')
%now I need to sum each column, for example the data in column 2 is for Copper
0 个评论
回答(1 个)
Star Strider
2022-5-20
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!