Matrix interference infinity loop

1 回表示 (過去 30 日間)
mohammed sportman
mohammed sportman 2012 年 12 月 22 日
When you put a value to the counter, for example more than 15 and at a number of attempts 10000. the matrix interference in Loop indefinitely What is the reason for this and how can I fix the problem
code
m=15;
klp=0;
for i=1:m
klp=klp+1;
lp(klp)=top;
end
lp(klp)=top interference to infinity loop
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 12 月 22 日
What are lp and top?

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

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 12 月 22 日
Are you sure it is an infinite loop, and not just very slow? You are not preallocating your output array, so every time you add more information to the array, MATLAB has to allocate a new block of memory just slightly larger, and copy the old array, then delete the old array -- for every iteration.
  7 件のコメント
mohammed sportman
mohammed sportman 2012 年 12 月 24 日
no my program code do not have try/catch in it how i can use it? and when i can put them (try / catch) in my program the problem just appear when i use large number of attempts (with same code and same condition) what is deference between large attempts and small(500 and 10000) attempt's in matlab with same program
mohammed sportman
mohammed sportman 2012 年 12 月 24 日
difference(deference)

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

カテゴリ

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