difference between adjacent elements of a vector
20 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Fidele Adanvo
el 28 de Nov. de 2020
Editada: Fidele Adanvo
el 28 de Nov. de 2020
If I need to calculate the difference between the adjacent elements and know the size of the vector a priori, you will know what to tell me?
Por exemple..
A=[1,4,6,10,33,200,..............................]; A is
out=[A(1)-A(2), A(2)-A(3), A(3)-A(4),...........A(n-1)-A(n)]
Important vector "A" do not follow any rule or sequence. A is a matrix of size n whose value of n is not known a priori.
0 comentarios
Respuesta aceptada
Ameer Hamza
el 28 de Nov. de 2020
Editada: Ameer Hamza
el 28 de Nov. de 2020
A = [1,4,6,10,33,200];
out = A(1:end-1) - A(2:end);
Read about indexing here: https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html
1 comentario
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!