Subtract row from previous row

26 vues (au cours des 30 derniers jours)
C Smyth
C Smyth le 12 Mar 2018
Commenté : Farhan Mustafa le 24 Mai 2020
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.

Réponse acceptée

Birdman
Birdman le 12 Mar 2018
x(1:end-1)-x(2:end)

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by