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
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (1)
Fake Name Johnson
am 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 Kommentare
May Kh
am 15 Mai 2021
DGM
am 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
am 15 Mai 2021
Plus, she asked specifically for a "for loop" though I'm not sure that is mandatory.
May Kh
am 16 Mai 2021
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!