- You might have a bug in your code.
- Your program might just take a long time to complete.
- You might have run out of memory and your program might be swapping to disk. When this happens, the whole system will get slow
- You might have a corrupt MATLAB installation.
- You might have an operating system problem.
- You might have hardware problems.
Why my coding keep running non stop?
38 views (last 30 days)
Show older comments
Hi. I wanna know why my coding keep running non stop? It doest display any error.
0 Comments
Answers (2)
Walter Roberson
on 14 Oct 2019
0 Comments
Image Analyst
on 14 Oct 2019
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
0 Comments
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!