How to get sum of columns even if the matrix is a row vector?

1 次查看(过去 30 天)
I'd like to get the sum of columns in a matrix, but when the matrix has only one row, the SUM function gives the sum of all elements in the row. How can I skip that? The ideal solution will return the row vector itself.

采纳的回答

Matt J
Matt J 2016-10-4
编辑:Matt J 2016-10-4
sum(theMatrix,1)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by