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 comentarios

the cyclist
the cyclist el 11 de Mzo. de 2021
Editada: the cyclist el 11 de Mzo. de 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.
REEMA MOHANTY
REEMA MOHANTY el 11 de Mzo. de 2021
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.
Jan
Jan el 11 de Mzo. de 2021
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?
REEMA MOHANTY
REEMA MOHANTY el 11 de Mzo. de 2021
Thank you so much for the answer .I will go through the code once again.
REEMA MOHANTY
REEMA MOHANTY el 12 de Mzo. de 2021
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.
Jan
Jan el 12 de Mzo. de 2021
Use the profile comamnd to find the bottlenecks of your code. If symsum is slow, there is not magic trick to increase the speed.
REEMA MOHANTY
REEMA MOHANTY el 15 de Mzo. de 2021
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.

Iniciar sesión para comentar.

Respuestas (0)

Etiquetas

Preguntada:

el 11 de Mzo. de 2021

Comentada:

el 15 de Mzo. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by