The search for means of absolute values โ€‹โ€‹of the second differences between the elements

I have a line vector like this: [1 5 6 -4 3] . I want to find the means of the absolute values โ€‹โ€‹of the second difference between the elements. The second difference in this example is: (6-1)=5 ,-4-5=-9 & 3-6=-3 , and the average absolute average is (5+9+3)/3=17/3 (6-1)=5 ,-4-5=-9 & 3-6=-3 .

Is there a way to use MATLAB's efficient matrix / massive manipulation to make it beautiful?

+4
source share
1 answer

For the second difference, you can do the following (v is your vector):

 v(3:end)-v(1:end-2) 

and from there to calculate the average abs olute, this is a really simple step.

+3
source

Source: https://habr.com/ru/post/1441430/


All Articles