Subtracting one row from a previous row in a single column of n long data
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jacob Allen
el 5 de Feb. de 2022
Comentada: Walter Roberson
el 10 de Feb. de 2022
I have a single column of data that is n long and I want to be able to subtract the second row in that column by the first and have that pattern repeat. (third row subtracted by the second, fourth row subtracted by the thrid and so on).
Ex:
1
5
6
7
4
3
I would like to be able to have a code that does 5-1, 6-5, 7-6, 4-7, 4-3.
I am pretty new to MatLab so if I am using incorrect terminology or my question is confusing in any way please let me know.
0 comentarios
Respuesta aceptada
Walter Roberson
el 5 de Feb. de 2022
A = randi(9, 8, 2) %some data to illustrate
diff(A, [], 1) %subtract row by row
0 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!