Reading a vector in intervals of 40.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuesta aceptada
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)
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!