フィルターのクリア

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

1 回表示 (過去 30 日間)
Mohammad Haghighat
Mohammad Haghighat 2016 年 10 月 4 日
編集済み: Matt J 2016 年 10 月 4 日
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 Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by