How to create a loop
Ältere Kommentare anzeigen
This is my code. How can i create a loop to remove dubble coding.
e(1) = ; %Primary expenditure at starting point
e(2) = e(1)*(1+ge)/(1+y);
e(3) = e(2)*(1+ge)/(1+y);
e(4) = e(3)*(1+ge)/(1+y);
e(5) = e(4)*(1+ge)/(1+y);
e(6) = e(5)*(1+ge)/(1+y);
e(7) = e(6)*(1+ge)/(1+y);
e(8) = e(7)*(1+ge)/(1+y);
e(9) = e(8)*(1+ge)/(1+y);
e(10) = e(9)*(1+ge)/(1+y);
e(11) = e(10)*(1+ge)/(1+y);
e(12) = e(11)*(1+ge)/(1+y);
e(13) = e(12)*(1+ge)/(1+y);
e(14) = e(13)*(1+ge)/(1+y);
1 Kommentar
Simpler to write vectorized code:
Antworten (2)
A geometric series really is simpler to write using vectorized code:
k = (1+ge)/(1+y);
e0 * k.^(0:13)
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!