Matlab App Erroneously detecting infinite loop

6 views (last 30 days)
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 Comment
Richard Good
Richard Good on 28 Sep 2022
I get this message in the window when the issue happens,
Error while evaluating DestroyedObject PrivatePushedButtonFcn
This is supposed to indicate an infinite loop I think, but I do not have an infinite loop, it just takes a long time sometimes. I have a for loop with 5 further for loops inside it to iterate over my simulink tests the way I want. I think Matlab has erroneously detected an infinite loop. How do I get over this/ switch off that check?

Sign in to comment.

Answers (1)

Eric Delgado
Eric Delgado on 30 Sep 2022
Edited: Eric Delgado on 30 Sep 2022
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 Comments
Eric Delgado
Eric Delgado on 6 Oct 2022
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

Sign in to comment.

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by