Filter löschen
Filter löschen

reduce running time of for loop

1 Ansicht (letzte 30 Tage)
Jason
Jason am 1 Mär. 2016
Beantwortet: Jan am 1 Mär. 2016
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 Kommentar
KSSV
KSSV am 1 Mär. 2016
avoiding loop will reduce time. It depends on what is that something to do ?

Melden Sie sich an, um zu kommentieren.

Antworten (2)

sakshi ahuja
sakshi ahuja am 1 Mär. 2016
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 am 1 Mär. 2016
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.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by