Addition of adjacent rows of a column matrix

4 ビュー (過去 30 日間)
KK14
KK14 2020 年 11 月 16 日
コメント済み: KK14 2020 年 11 月 19 日
Hello, here is a part of my code where I am trying to add adjacent rows, i.e a(R1)+a(R2) =b(R2), a(R2)+a(R3) = b(R3) and so on. Could anyone please help me solve the issue of exceeding array bounds in position 1.
i = 2:500;
j = 2:500;
if ( i == j)
b(j,1) = a(i,1) + a(i-1,1)+ b(j-1,1);
end
Thanks in advance!

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 16 日
You can use movmean()
x = rand(100, 1);
y = movmean(x, 2, 'Endpoint', 'discard')
  1 件のコメント
KK14
KK14 2020 年 11 月 19 日
Hello,
Thanks for the help. I shall try it out.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePreprocessing Data についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by