Matlab subtracting matrix elements

社会主义新天地 提交于 2019-12-02 13:58:44

diff does what you want.

diff(data)

BUT if you want to continue with your approach, I imagine the error you get is related to data(i-1) cannot be defined when i = 1. Your loop should be 2:cnt.

Another method would be data(2:end) - data(1:end-1)

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