How can I create a for loop that takes the number 500 and multiplies it by 1.1 every 7 steps (7,14,21,...), meaning that i want the answer as follows: 500.... 500*1.1....500*1.1*1.1....500*1.1*1.1*1.1 etc
Afficher commentaires plus anciens
How can I create a for loop that takes the number 500 and multiplies it by 1.1 every 7 steps (7,14,21,...), meaning that i want the answer as follows: 500.... 500*1.1....500*1.1*1.1....500*1.1*1.1*1.1 etc
Réponse acceptée
Plus de réponses (1)
Fake Name Johnson
le 15 Mai 2021
Here's a start
a = 500;
k = 1.1;
p = 0:5;
s = 7;
x = a*k.^p;
x = repelem(x,s)
just adjust p as needed to get the desired length.
5 commentaires
May Kh
le 15 Mai 2021
DGM
le 15 Mai 2021
repelem() has been builtin since R2015a, so I guess you're running an older version. You can do the same thing without it.
x = reshape(repmat(x,[s 1]),[],1).'
Image Analyst
le 15 Mai 2021
Plus, she asked specifically for a "for loop" though I'm not sure that is mandatory.
May Kh
le 16 Mai 2021
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!