필터 지우기
필터 지우기

Why my coding keep running non stop?

조회 수: 28 (최근 30일)
Najwa Samlan
Najwa Samlan 2019년 10월 14일
답변: Image Analyst 2019년 10월 14일
Hi. I wanna know why my coding keep running non stop? It doest display any error.

답변 (2개)

Walter Roberson
Walter Roberson 2019년 10월 14일
  1. You might have a bug in your code.
  2. Your program might just take a long time to complete.
  3. You might have run out of memory and your program might be swapping to disk. When this happens, the whole system will get slow
  4. You might have a corrupt MATLAB installation.
  5. You might have an operating system problem.
  6. You might have hardware problems.

Image Analyst
Image Analyst 2019년 10월 14일
A common bug that Walter mentioned is an infinite loop caused by not having an iteration limit on a while loop so that the while loop never ends. ALWAYS have an iteration loop as a failsafe:
maxIterations = 1000000; % Or whatever you think the max will ever be
condition = true; % Or some other initialization...
numIterations = 0; % Loop counter
while condition && (numIterations < maxIterations)
% FIrst update condition somehow...
% Then update loop counter
numIterations = numIterations + 1;
end
if numIterations >= maxIterations
message = sprintf('Loop exited early because the maximum number of iterations (%d) was reached', numIterations)
uiwait(warndlg(message));
end

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by