Matlab App Erroneously detecting infinite loop
显示 更早的评论
Hello Gurus,
I have a matlab application that acts as a wrapper to Simulink Test. Some of the Tests can take a very long time to run, I'm talking several hours. When I run one of these tests that involves many iterations the application closes down during the activity. As the data for simulink test is actually loaded on to the Tree I use to display the tests this means that the next Test fails. The weird thing is I can run hundreds of single iteration tests without issue and the issue does not have anything to do with a license I think as I selected to borrow a license for the whole day just in case. The app gives me no errors or warnings it just closes itself down on the long running iterations. Any ideas/ tips appreciated.
Cheers
Richard
回答(1 个)
Eric Delgado
2022-9-30
编辑:Eric Delgado
2022-9-30
It sounds like a limitation of the foor loops. For example, if you create e for loop from 1 to a BigNumberAlmostInfinite you will receive the warning "Too many FOR loop iterations. Stopping after 9223372036854775806 iterations."
Just replace it for while loops.
% Instead of:
for ii = 1:BigNumberAlmostInfinite
% code
end
% Do:
ii = 0;
while true
ii = ii+1;
% code
if ii == BigNumberAlmostInfinite
break
end
end
2 个评论
Richard Good
2022-10-6
Eric Delgado
2022-10-6
Even though you said that the app shows no error or warning messages, did you try to protect your code with a try/catch block?
for ii = 1:BigNumberAlmostInfinite
try
% code
catch ME
% put a break point in here and share the info of ME
end
end
类别
在 帮助中心 和 File Exchange 中查找有关 Test Model Components 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!