필터 지우기
필터 지우기

adding adjacent n elements in a matrix

조회 수: 4 (최근 30일)
OLUBUKOLA ogunsola
OLUBUKOLA ogunsola 2016년 6월 26일
댓글: OLUBUKOLA ogunsola 2016년 6월 26일
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
Stephen23
Stephen23 2016년 6월 26일
Pick N to suit:
conv2(A,ones(1,N),'valid')
OLUBUKOLA ogunsola
OLUBUKOLA ogunsola 2016년 6월 26일
Thanks

댓글을 달려면 로그인하십시오.

추가 답변 (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