Finding means of the absolute values of second differences between elements

泪湿孤枕 提交于 2019-12-12 11:24:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!