any way to avoid this loop?
Mostrar comentarios más antiguos
I'm familiar with the benefits of vectorizing code, but is there a way to avoid a loop when the solution to each value in an array depends on the value before it? A minimal working example of a loop I'd like to avoid:
x = ones(1,1000);
for n = 2:length(x)
x(n) = 2*x(n-1) - 10;
end
Ideas for a generalized solution? Or perhaps there's simply a faster technique I should learn about?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!