Using diff(x) function to create a new table by subtracting values from the previous row
Show older comments
I was trying to create a new table from a set of data that I have. I've attached the dataset to this question and a picture so I can explain what I want to do.

Using this data, I want to first eliminate all the empty boxes (NaNs in matlab) so that the data stacks directly on top of itself. For example, here is an example using a small subset of data.

Now using this data, what I want to do is create a new table that subtracts values of one row from the PREVIOUS row and puts them into a new spot an array. For example, for the previous dataset:

From what I have read so far, I believe the best function to use is the diff(x) documentation but I haven't been able to figure out how to implement the values I receive from it and put them into a new array
Accepted Answer
More Answers (0)
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!