Azzera filtri
Azzera filtri

is there any faster way to operate a group of statements in a loop only once, than applying if else

2 visualizzazioni (ultimi 30 giorni)
for .........
statemets 1;
statements 2:
if iteration == 0
[value1,value2] = function(args1,args2); %dependent on statment 1 and 2
statement 3;%dependent on statement 1 and 2
statement 4;%dependent on statement 1 and 2
end
other statements;
end

Risposte (1)

Walter Roberson
Walter Roberson il 16 Set 2018
Yes, you can unroll.
[value1,value2] = function(args1,args2);
statement 1;
statement 2;
for iteration = .... %same bounds as before because you still want other statements to be done for the initial iteration
other statements;
end
  2 Commenti
Walter Roberson
Walter Roberson il 16 Set 2018
Unrolling is still the answer.
statements 1;
statements 2:
[value1,value2] = function(args1,args2); %dependent on statment 1 and 2
statement 3;%dependent on statement 1 and 2
statement 4;%dependent on statement 1 and 2
other statements;
for iteration = 1 : ... %skip the first iteration where iteration = 0
statemets 1;
statements 2:
other statements;
end

Accedi per commentare.

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by