How can i add all column values in a pattern and save simultaneously?

1 回表示 (過去 30 日間)
suchismita
suchismita 2016 年 5 月 19 日
編集済み: dpb 2016 年 5 月 19 日
I have a matrix as
Px=[ Columns 1 through 9
0.0574 0.0574 0.0574 0.0015 0.0112 0.0112 0.0574 0.0112 0.0574
Column 10
0.0112]
Now i want to add columns 1 to 10 and save first then add column 2 to 10 and goes on
PX=[Px(1)...+Px(10) Px(2)...+Px(10) Px(3)..+Px(10) Px(4)..+Px(10) Px(5)..+Px(10) Px(6)..+Px(10) Px(7)..+Px(10) Px(8)..+Px(10) Px(9)..+Px(10) Px(10)]
Please help me.... please please....

採用された回答

dpb
dpb 2016 年 5 月 19 日
編集済み: dpb 2016 年 5 月 19 日
Px=fliplr(cumsum(fliplr(C)));
PS. In future, don't whine, it isn't becoming... :)
PPS
You can avoid one function call by writing the inner index reversal explicitly--I've no idea if would make any performance difference for large vector sizes or not.
Px=fliplr(cumsum(C(end:-1:1)));
Matlab doesn't have postfix indexing expressions so can't avoid the outer call.

その他の回答 (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