MATLAB: Problem with while loop

MATLAB

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

Best Answer

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.