Problem with while loop
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Kallam Haranadha Reddy
el 19 de Oct. de 2017
Comentada: Kallam Haranadha Reddy
el 19 de Oct. de 2017
I wrote 3 functions and i wanted to link them in main function. In the main function i wrote a while loop . i am facing problem with this while loop. . The loop is running with initial values, i.e., it is not updating the values of rcapa, capaPAMin, and Bineq. The main function runs as follows
How to correct this problem.
global Bineq1; capaPAMin = inf; Bineq2 = capaPAMin; Bineq = vertcat(Bineq1,Bineq2); iter = 1; while(iter <=15) DA2 = @(Bineq,capaPAMin) somefunction(c1,c2,c3,c4,c8,capaPAMin,Aineq,Bineq,Aeq,Beq,lb2,ub2); [yd2,DAC2] = DA2(Bineq,capaPAMin); td2 = yd2(1345:1728); -- -- -- rcapa -- -- PA2 = @(rcapa) somotherfunction(c5,c6,c7,Aineq,Bineq,Aeq,rcapa,lb1,ub1); [yp2,PAC2] = PA2(rcapa); b = yp2(385:576); -- -- capaPA -- -- if capaPAMin > capaPA capaPAMin = capaPA; end Bineq2 = capaPAMin; Bineq = vertcat(Bineq1,Bineq2); iter = iter + 1; end
2 comentarios
KL
el 19 de Oct. de 2017
Please format your code. To do that, select the code in your question, click the {} Code button. That way, it is much easier to read.
Respuesta aceptada
KL
el 19 de Oct. de 2017
Editada: KL
el 19 de Oct. de 2017
In the code you've provided, the variables ( rcapa, capaPA) are not defined.
Moreover even if you define it in the beginning, they are not influenced by any of your functions. So they wouldn't change but stay in its initial conditions.
1 comentario
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!