Desplazate a vector one unity to the right.

1 次查看(过去 30 天)
I have a vector of lenght N, I want to have another vector with the same size but translated to the right. Ex:
x=n1:n2;
y=x(n)-x(n-1);
It's like an discrete differenciation.
Any idea of how to do that?

回答(1 个)

Walter Roberson
Walter Roberson 2015-11-18
You can define
y = x(2:end) - x(1:end-1)
or you can use the built-in routine
y = diff(x)
However, either way this only defines N-1 values and does not define what the N'th value should be.

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by