フィルターのクリア

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

2 ビュー (過去 30 日間)
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

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 9 月 16 日
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 件のコメント
Walter Roberson
Walter Roberson 2018 年 9 月 16 日
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

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by