how to optimize a loop

조회 수: 3 (최근 30일)
Amina Ben Abbou
Amina Ben Abbou 2022년 1월 11일
답변: Nihal Reddy 2022년 1월 25일
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
Walter Roberson
Walter Roberson 2022년 1월 11일
Sometimes you can vectorize. Sometimes the only alternative to a for loop is a hidden for loop such as arrayfun
KSSV
KSSV 2022년 1월 11일
And we cannot help you unless the code is shown here and what cycles you want to optimize.

댓글을 달려면 로그인하십시오.

답변 (1개)

Nihal Reddy
Nihal Reddy 2022년 1월 25일
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.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by