필터 지우기
필터 지우기

substract an element from previous element in a matrix

조회 수: 2 (최근 30일)
Mahmoud Chawki
Mahmoud Chawki 2022년 5월 10일
댓글: Star Strider 2022년 5월 10일
i have a k vector that contains 5 elements.
i want to write a code that substract - the second element from first
- the third element from second
- the fourth element from third
- the fifth element from fourth
and put them all in a vector form that will contain 4 elements
b=[k(2)-k(1) k(3)-k(2) k(4)-k(3) k(5)-k(4)];
how can i do that?

답변 (1개)

Star Strider
Star Strider 2022년 5월 10일
The diff function seems to be appropriate.
  댓글 수: 3

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

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by