问题
I have a row vector like so: [1 5 6 -4 3]
. I want to find means of absolute values of second difference between elements. The second differences in this example are (6-1)=5 ,-4-5=-9 & 3-6=-3
, and the average absolute mean is (5+9+3)/3=17/3
.
Is there some way of using MATLAB's efficient matrix/array manipulation to do this nicely?
回答1:
For the second difference you can do the following (v is your vector):
v(3:end)-v(1:end-2)
and from there to calculating the mean of the abs olute value, its really a simple step.
来源:https://stackoverflow.com/questions/13022814/finding-means-of-the-absolute-values-of-second-differences-between-elements