adding adjacent n elements in a matrix

4 次查看(过去 30 天)
if i have a matrix like A= (1 2 3 4;5 6 7 8;9 10 11 12 ; 13 14 15 16) adding three adjacent elements will look like A(i,j)+A(i,(j+1))+A(i,(j+2)) how can i do this for n adjacent elements ?

采纳的回答

Andrei Bobrov
Andrei Bobrov 2016-6-26
A= [1 2 3 4;5 6 7 8;9 10 11 12 ; 13 14 15 16];
out = conv2(A,[1 1 1],'valid')
  3 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by