how to optimize a loop

10 visualizaciones (últimos 30 días)
Amina Ben Abbou
Amina Ben Abbou el 11 de En. de 2022
Respondida: Nihal Reddy el 25 de En. de 2022
Hello.
I would like to ask if someone can suggest me a way to replace a for loop with a new/other function.Cause while I was working I realize I was using too many for loops.
Thanks
  2 comentarios
Walter Roberson
Walter Roberson el 11 de En. de 2022
Sometimes you can vectorize. Sometimes the only alternative to a for loop is a hidden for loop such as arrayfun
KSSV
KSSV el 11 de En. de 2022
And we cannot help you unless the code is shown here and what cycles you want to optimize.

Iniciar sesión para comentar.

Respuestas (1)

Nihal Reddy
Nihal Reddy el 25 de En. de 2022
Hey Amina,
From my understanding, you want a replacement or alternative for for loop. In some of the cases, you can vectorize, and in the other cases, you can use a function that does the role of for loop for your specific requirement.
Refer to the following MATLAB Documentation page on how vectorization can be used in place of for loop.

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by