matlab get stop executing while loop for no reason

Hello everyone:
I am facing a strange problem with Matlab. I have a while loop that should execute optimization function "fminmax". The problem is that suddenly the program stop working it is like it froze. It does not finish the execution, it does not end it also, nothing..as shown in figure bellow.
Does anyone here have an idea why this happen????
Thank you in advance.

9 Comments

You're just stuck in an infinite loop. Chance are that the variable may not be meeting the condition you set for the while loop.
no the loop is not infinite we are sure that the function will converge and even if it does not converge the program should not just stop like that without moving .. you see the j bellow counts the iterations done by the loop it is fix
The screenshot does not contain any useful information. Please restart Matlab and/or the computer to check, if the problem is reproducible. If so, post the relevant part of the code. Perhaps you only requested a rand(1e6) and the computer stalls while trying to reserve a 10 TByte array.
Bellow you will find the part where Matlab get stuck. It is an implementation of Dinkelbach algorithm. For simulation, I am using a matlab version installed on the server.
while maxfval >= epsilon
[x,~,maxfval,exitflag] = fminimax(@(x) FP_function(sigma2, nbr_R, x, h, H, Sc, lambda1), x, [], [], [], [], lb, ub,... @(x) nonlconstr(sigma2, nbr_R, x, h, H, Sc, rates))
[~, sum_rate, sum_Power] = SINR_Rate(sigma2, nbr_R, x, h, H, Sc)
lambda1 = min(sum_rate./ sum_Power)
maxfval=abs(maxfval)
j=j+1 % just to calculate iterations
end
Print your maxfval and see if it ever gets smaller than the epsilon. If not, increase the epsilon.
the behavior is not as an infinite loop. The code just stop no condition checking, no error msg just stop in j=j+1
What is the error message? Have you initialized j somewhere in the code? Also, there should be a ';' between maxfval=abs(maxfval) and j=j+1
yes i initialized before while loop and i took out ; to see the value in the commend line and again there is not error msg, matlab does not stop executing the code at all and does not continuous as well. It just stop
Well then it seems that maxfval becomes smaller than epsilon in the first run. Try changing epsilon. It would be easier for me to understand if you can share the entire code.

Sign in to comment.

Answers (0)

Categories

Tags

Asked:

on 4 May 2016

Commented:

on 4 May 2016

Community Treasure Hunt

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

Start Hunting!