There are a lot of functions on my work and purpose of using fmincon correctly, i should change final function. This code gives me results, but with the changing of final function, variable number increased.
WR_acc=@(acc_val) sum(0.01.*(1+(ref+[1:numel(acc_loc:ramp_loc-1)]*acc_val)*3.6/160)*18000*cos(0)); %
WS_acc=0;WL_acc=@(acc_val) sum(0.5.*(ref+[1:numel(acc_loc:ramp_loc-1)]*acc_val).^2);WB_acc=@(acc_val) sum((1.04+0.0025*mean(TCO))*bos_kutle*(((ramp_loc-1).*acc_val+ref)^2-(acc_val+ref)^2)/(2*numel(acc_slo)*mesafe_araligi)); TL_acc=@(acc_val) WB_acc(acc_val)+WR_acc(acc_val)+WS_acc+WL_acc(acc_val);WR_dec=@(dec_val,acc_val) sum(0.01.*(1+(ref+numel(acc_slo)*acc_val-dec_val.*[1:numel(ramp_loc:deg(end)-1)])*3.6/160)*18000.*cos(ramp_slo'));WS_dec=sum(18000*sin(ramp_slo'));WL_dec=@(dec_val,acc_val) sum(0.5.*(ref+numel(acc_slo)*acc_val-dec_val*[1:numel(ramp_loc:deg(end)-1)]).^2);WB_dec=@(dec_val,acc_val) sum((1.04+0.0025*mean(TCO))*bos_kutle*((-(numel(ramp_slo)).*dec_val+ref+numel(acc_slo)*acc_val)^2-(-dec_val+ref+numel(acc_slo)*acc_val)^2)/(2*numel(ramp_slo)*mesafe_araligi));TL_dec=@(dec_val,acc_val)WB_dec(dec_val,acc_val)+WR_dec(dec_val,acc_val)+WS_dec+WL_dec(dec_val,acc_val);TL=@(YH) TL_acc(YH(2))+TL_dec(YH(1),YH(2)); %FINAL FUNCTION
x0=[0,0];A=[1,-2];b= 0.152778;Aeq=[];beq=[];lb=[0,0];ub=[];YH=fmincon(TL,x0,A,b,Aeq,beq,lb,ub)
When i use YH(1) and YH(2); variable number up 2 to 4 (dec_val,acc_val and YHs). But number of optimization results is 2.
Where is my mistaken here? Should i change dec_val as YH(1) and acc_vall as YH(2)?
Thanks a lot.
Best Answer