Increment the value inside another loop
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mushahid Shamim
el 25 de Abr. de 2018
Comentada: Mushahid Shamim
el 26 de Abr. de 2018
for i=1:10
if(true)
while(true)
i=i+1;
end
end
end
will this increment or update the value of i ?
2 comentarios
Respuesta aceptada
Hunter Bates
el 25 de Abr. de 2018
@Mushahid Shamim: This will run in a inf loop. Need a condition to break the while statement. for i=1:10 if(true) while(true) i=i+1 break end end end end Please describe the workflow which you are trying to achieve, assuming this isn't for m-code 101
3 comentarios
Dennis
el 26 de Abr. de 2018
why should your while loop break? I am pretty sure that your for loop doesnt even care if you change i somewhere it will still run from 1:10.
If you want your inner loop to iterate 4 times why are you using while?
while it<=10
for i=1:4
it=it+1;
end
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!