Desplazate a vector one unity to the right.

1 visualización (últimos 30 días)
Carlos Martínez
Carlos Martínez el 18 de Nov. de 2015
Respondida: Walter Roberson el 18 de Nov. de 2015
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?

Respuestas (1)

Walter Roberson
Walter Roberson el 18 de Nov. de 2015
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.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by