Problem occurs with the infinite loop

I am working with many for loops. So I can't detect which syntax leads to infinite loop.
My query is "I am getting a plot while breaking the loop. Could the plot be accepted as a correct answer?"

7 Comments

the cyclist
the cyclist on 11 Mar 2021
Edited: the cyclist on 11 Mar 2021
Try to imagine you are someone else reading this forum, and the only thing you know about your problem is what you have written here.
Maybe that will help you realize that you have not given us enough information to help. Not even close to enough information.
Okay .So I have been trying to code a Particle swarm optimization algorithm where I have used multiple for loops.
I can't post the entire code as it is of 180 lines.The problem is , it has gone into infinite loop condition,still it gives me a result while pausing the code.
My question is " Is the result acceptable?"
I hope i am clear with my queries.Please let me know for any further details.
Nested FOR loops cannot cause an infinite loop. Only WHILE loops can be infinite.
How is the term "acceptable" defined in your case? There is no unique definition. Maybe to substantianl advance in the last 100 iterations?
Thank you so much for the answer .I will go through the code once again.
Hii.I went through the code.I have been trying to maximize the profit scenario.
so the main function is - : fprofit = symsum(f2,Zka1,0, 105000)-symsum(f1,Zka,0, 150000)- symsum(f2,Zka,105000)
is it the reason that the upper boundary is 105000,it takes so many iterations?
I have tried to use break points and saw that I get the fprofit value in each iteration.
Please help me through it.
Use the profile comamnd to find the bottlenecks of your code. If symsum is slow, there is not magic trick to increase the speed.
I have used the profile command and got to know about the time taken by each syntax,
but there is one warning in profile window as "This function changed during profiling or before generation of this report. Results may be incomplete or inaccurate."
Should I be worried about it?" I have attached the screenshot below.

Sign in to comment.

Answers (0)

Asked:

on 11 Mar 2021

Commented:

on 15 Mar 2021

Community Treasure Hunt

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

Start Hunting!