Subtract row from previous row

26 ビュー (過去 30 日間)
C Smyth
C Smyth 2018 年 3 月 12 日
コメント済み: Farhan Mustafa 2020 年 5 月 24 日
I have a column of data (n long) and I want to subtract each row from the previous. So x = 1 2 6 1 etc
and I want to subtract row 2 from row 1, then row 3 from row 2 ... etc. Ans = -1 -4 5 etc.

採用された回答

Birdman
Birdman 2018 年 3 月 12 日
x(1:end-1)-x(2:end)
  1 件のコメント
Farhan Mustafa
Farhan Mustafa 2020 年 5 月 24 日
diff(x)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by