フィルターのクリア

Sum over columns excluding rows

2 ビュー (過去 30 日間)
Javier
Javier 2014 年 1 月 13 日
コメント済み: Javier 2014 年 1 月 14 日
Hi, I am quite a begginer with matlab and I wonder if someone could help me with this problem.
I have a matrix
A=[a b c d;
e f g h;
i j k l;
m n o p]
I want to get the sum of each row and then perform the same operating excluding the first column, then excluding the first two columns and then the first three columns and put all this results in a matrix. I want something like this
B=[a+b+c+d b+c+d c+d d;
e+f+g+h f+g+h g+h h;
i+j+k+l j+k+l k+l l;
m+n+o+p n+o+p o+p p]
Do you know how can I get the this result in a effiicient way? I have four columns in the example but more than 10,000 in the real problem.
Thank you in advance. Javier

採用された回答

José-Luis
José-Luis 2014 年 1 月 13 日
編集済み: José-Luis 2014 年 1 月 13 日
your_mat = flipud(cumsum(flipud(A')))'
  1 件のコメント
Javier
Javier 2014 年 1 月 14 日
This works perfectly, I did not know these functions. Thank you very much!!

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 1 月 13 日
編集済み: Azzi Abdelmalek 2014 年 1 月 13 日
A = [1 2 3 4; 2 4 6 0; 3 1 2 5; 1 1 1 3]
out=fliplr(cumsum(fliplr(A),2))
  1 件のコメント
Javier
Javier 2014 年 1 月 14 日
Thank you very much!

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

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by