Effacer les filtres
Effacer les filtres

Reading a vector in intervals of 40.

3 vues (au cours des 30 derniers jours)
Ricardo Gutierrez
Ricardo Gutierrez le 2 Oct 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

Réponse acceptée

Walter Roberson
Walter Roberson le 2 Oct 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))
  1 commentaire
Ricardo Gutierrez
Ricardo Gutierrez le 2 Oct 2019
Excellent !!!!
It worked
Thank you so much.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Produits


Version

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by