How to sum part of a column?

12 ビュー (過去 30 日間)
Karl
Karl 2013 年 4 月 29 日
回答済み: Birabhadra Rout 2017 年 8 月 25 日
Hi. I am new to Matlab.
Does anybody know how I can calculate the column sum of row 1 and 2 in column 3 in the follwoing matrix (3+6)?
1 2 3
4 5 6
7 8 9

採用された回答

Kye Taylor
Kye Taylor 2013 年 4 月 29 日
編集済み: Kye Taylor 2013 年 4 月 29 日
If your matrix is called A, then rows 1 and 2 in column 3 can be identified with the syntax
A( 1:2, 3 )
So sum it using the command
sum( A( 1:2, 3 ) )
  1 件のコメント
Karl
Karl 2013 年 4 月 29 日
Thank you very much!

サインインしてコメントする。

その他の回答 (1 件)

Birabhadra Rout
Birabhadra Rout 2017 年 8 月 25 日
if i have a matrix of vecor 1 2 1 3 1 4 2 2 2 3 2 4 and i want to add each number in 2nd column with having similar data in 1 st column and i want to save it as 1 9 2 10 then how to do it ?

カテゴリ

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