フィルターのクリア

how do obtain sum of two rows

7 ビュー (過去 30 日間)
Johannes Deelstra
Johannes Deelstra 2017 年 12 月 14 日
編集済み: Johannes Deelstra 2017 年 12 月 15 日
Have a 18482 x 7 matrix. I want to obtain a matrix which contains the sum of row 1 and 2, row 3 and 4, etc until the last ones being the sum of row 18481 and 18482. How do I do this. Thanks in advance

回答 (2 件)

Walter Roberson
Walter Roberson 2017 年 12 月 14 日
output = YourMatrix(1:2:end, :) + YourMatrix(2:2:end, :);
  2 件のコメント
Rik
Rik 2017 年 12 月 14 日
That's what you get with ambivalent questions, there are multiple answers that fit the question.
Johannes Deelstra
Johannes Deelstra 2017 年 12 月 15 日
編集済み: Johannes Deelstra 2017 年 12 月 15 日
thanks for answering, two solutions, helpful

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


Rik
Rik 2017 年 12 月 14 日
x=rand(18482,7);
x2=sum(x,2);
x2=x2(1:2:end)+x2(2:2:end);

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by