Optimization on for loop and if statement

Hi,
Is there any alternative way to improve these statements ?
for i = 1:telegramCount
for k = 1:calculationCount
if(telArray(i,1) == sortedArray(k,3))
firstPlace = k;
break;
end
end
end
Thanks in advance.

回答 (1 件)

Vladimir Sovkov
Vladimir Sovkov 2019 年 11 月 19 日

0 投票

firstPlace = find ( telArray(i,1) == sortedArray(:,3) ,1 )
replaces your entire "k" loop.

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2019 年 11 月 18 日

編集済み:

Jan
2019 年 11 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by