Reading a vector in intervals of 40.

2 visualizaciones (últimos 30 días)
Ricardo Gutierrez
Ricardo Gutierrez el 2 de Oct. de 2019
Comentada: Ricardo Gutierrez el 2 de Oct. de 2019
Hi. Good day.
I would like to help me in the following:
I have a vector A
A = [14 8 12 18 8 34 24 14 12 22 2 20 2 10 16 8 10 18];
I want to add 0 to the first vector element A; 0 + 14 = 14
__ to the second element add 40; 40 + 8 = 48
__ to the third element add 80; 80 + 12 = 92
__ to the fourth element add 120; 120 + 18 = 138
__ to the fifth element add 160; 160 + 8 = 168
and so on (40 by 40).
I have tried with " for " cycles and I have not been able to do it.
In the end the searched vector would be:
[14 48 92 138 168 234 264 294 332 422 442 500 522 570 616 648 690]
Thank you

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Oct. de 2019
A = [14 8 12 18 8 34 24 14 12 22 2 20 2 10 16 8 10 18];
A + (0:length(A)-1) * 40
A + (0:40:40*(length(A)-1))

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Productos


Versión

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by