Addition of adjacent rows of a column matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
채택된 답변
Ameer Hamza
2020년 11월 16일
You can use movmean()
x = rand(100, 1);
y = movmean(x, 2, 'Endpoint', 'discard')
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!