how to change the increment in for loop?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
I have this line of code in C++ and I need to know its equivalent in Matlab:
for (i =0 , i<100 , i=i+4)
?
0 Commenti
Risposta accettata
madhan ravi
il 1 Ago 2018
Modificato: madhan ravi
il 1 Ago 2018
hi, this is how you do it:
for i = 0:4:(100-1)
i
end
EXPLANATION: O IS THE STARTING POINT AND 4 IS THE INCREMENT , IT GOES ALL THE WAY UP UNTIL THE LIMIT (100-1)<=>99
2 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!