필터 지우기
필터 지우기

Create a new vector by adding and subtracting each element of original vector.

조회 수: 3 (최근 30일)
Hello community,
I want to create a new vector by adding and subtracting each element of orginal vector. How can I do?
Example: A = [3 8 99 61]
What I want is: Output B = [2 3 4 7 8 9 98 99 100 60 61 62]

채택된 답변

madhan ravi
madhan ravi 2019년 8월 6일
B = reshape(A + [-1;0;+1],1,[]) % or
B = reshape(bsxfun(@plus,A,[-1;0;+1]),1,[]) % if < = 2016a
  댓글 수: 3
madhan ravi
madhan ravi 2019년 8월 6일
Thanks Adam :), at first sight the question seemed to be unclear actually.

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

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