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
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (1)
Fake Name Johnson
il 15 Mag 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 Commenti
May Kh
il 15 Mag 2021
DGM
il 15 Mag 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
il 15 Mag 2021
Plus, she asked specifically for a "for loop" though I'm not sure that is mandatory.
May Kh
il 16 Mag 2021
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!