reduce running time of for loop

Assume I have a code as below, how do we rewrite, so we can great reduce running time?
for i = 1: 500
% something to do
end

댓글 수: 1

KSSV
KSSV 2016년 3월 1일
avoiding loop will reduce time. It depends on what is that something to do ?

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

답변 (2개)

sakshi ahuja
sakshi ahuja 2016년 3월 1일

0 개 추천

Function can be formed and relate this to your main work i.e., something u have to do, this will reduce your running time.
Jan
Jan 2016년 3월 1일

0 개 추천

There is no magic command to increase the speed like:
superspeedFor i = 1: 500
% something to do
end
As said before: You have to accelerate "something to do". If you can vectorize this part, the loop can be omitted, which is much faster in many situations.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2016년 3월 1일

답변:

Jan
2016년 3월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by