Filter löschen
Filter löschen

how to change the increment in for loop?

4 Ansichten (letzte 30 Tage)
Sarah A
Sarah A am 1 Aug. 2018
Bearbeitet: madhan ravi am 2 Aug. 2018
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)
?

Akzeptierte Antwort

madhan ravi
madhan ravi am 1 Aug. 2018
Bearbeitet: madhan ravi am 1 Aug. 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 Kommentare
Sarah A
Sarah A am 1 Aug. 2018
Thank you :)
madhan ravi
madhan ravi am 2 Aug. 2018
Bearbeitet: madhan ravi am 2 Aug. 2018
you're welcome

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by