while loop performance improvement
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
cglr
el 17 de Nov. de 2019
Hello everyone,
What is the alternative of while loop for the example:
rate = 2;
while (k <= period)
sum = sum + array(k,2);
k = k + rate;
end
Thanks.
0 comentarios
Respuesta aceptada
Fabio Freschi
el 17 de Nov. de 2019
I don't know the starting value of k, assuming it is 1
idx = 1:rate:period
mysum = sum(array(idx,2)); % note that sum is the name of a matlab function
1 comentario
Más respuestas (0)
Ver también
Categorías
Más información sobre Environment and Clutter 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!