Azzera filtri
Azzera filtri

for del=-1:0.5:1, i want to get the index of the value of del being used for that specific iteration . can anyone please tell me a way to do this

2 visualizzazioni (ultimi 30 giorni)
I am running a for loop "for del=-1:0.5:1" and i want to get the index of the value of del being used for the iteration lets say that its the 2nd iteration so i want to get the index of 2nd value of del

Risposta accettata

sixwwwwww
sixwwwwww il 19 Ott 2013
Dear Qasim, the index in the 2nd value of del will be 2. You can do like this:
count = 1;
for del = -1:0.5:1
fprintf('Iteration # = %d\n', count);
count = count + 1;
end
Or if you need something else then please state your question again clearly
  1 Commento
Qasim Manzoor
Qasim Manzoor il 19 Ott 2013
oh man stupid me. it was so simple and obvious. i was going through the programmers equivalent of writer's block. thanks alot. the count thing will accomplish what i needed.

Accedi per commentare.

Più risposte (0)

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!

Translated by