problem writing a seemingly easy summation
古いコメントを表示
hi everyone I have this matrix P and for each column j I need to have a summation from second row to end, or i=2:end
for example
P=[1 3 5 7;3 5 7 9;2 4 6 8];
now the matrix I am looking for is [5 9 13 17]
but no matter how I try to write it the answer is second row only
can someone help?
thank u in advance
採用された回答
その他の回答 (1 件)
Guillaume
2014 年 8 月 15 日
0 投票
sum(P(2:end, :))
8 件のコメント
alexaa1989
2014 年 8 月 15 日
Guillaume
2014 年 8 月 15 日
have you tried the command? It produces exactly what you asked for
>>P=[1 3 5 7;3 5 7 9;2 4 6 8];
>>sum(P(2:end, :))
ans =
5 9 13 17
alexaa1989
2014 年 8 月 15 日
alexaa1989
2014 年 8 月 15 日
Adam
2014 年 8 月 15 日
rehash toolboxcache
should fix that I think
Guillaume
2014 年 8 月 15 日
Can you copy and paste EXACTLY what you wrote in matlab?
I doubt it has anything to do with the path cache (unless you've created your own sum function). Restart matlab to update the cache.
alexaa1989
2014 年 8 月 15 日
alexaa1989
2014 年 8 月 15 日
カテゴリ
ヘルプ センター および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!