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

1 view (last 30 days)
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

Answers (1)

Walter Roberson
Walter Roberson on 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 Comments
Walter Roberson
Walter Roberson on 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

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!