Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
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

Antworten (1)

Walter Roberson
Walter Roberson am 16 Sep. 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 Kommentare
Walter Roberson
Walter Roberson am 16 Sep. 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

Melden Sie sich an, um zu kommentieren.

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