function [c,Cx]=func_eq_constr_old(VV,connect_m,YBUS,z_Pinj,z_Qinj,z_Pflow,z_Qflow,slack)
%,line,nob,nol,slack)
nob=length(VV(:,1));
G=real(YBUS);B=imag(YBUS);
S_calc=VV.*conj(YBUS*VV);%complex power injection vector (calculated)
%VM=abs(VV);VA=angle(VV);

Cx=[];c=[];
V=abs(VV);Ang=angle(VV);
if isempty(z_Pinj)==0
    for i=1:length(z_Pinj)
        k=z_Pinj(i);
        temp1=real(S_calc(k));temp2=imag(S_calc(k));
        %del P/ del theta as well as del P/ del V
        temp_Cx(1,1:2*nob)=0;
        for j=1:nob            
            if k==j
                temp_Cx(1,k)=-temp2-V(k)*V(k)*B(k,k);%del P/ del theta
                temp_Cx(1,k+nob)=(temp1+V(k)*V(k)*G(k,k))/V(k);%del P/ del V
            else
                if connect_m(k,j)==1
                    temp_Cx(1,j)=V(k)*V(j)*(G(k,j)*sin(Ang(k)-Ang(j))-B(k,j)*cos(Ang(k)-Ang(j)));
                    temp_Cx(1,j+nob)=V(k)*(G(k,j)*cos(Ang(k)-Ang(j))+B(k,j)*sin(Ang(k)-Ang(j)));
                end
            end
        end
        c=[c;temp1];%error vector for real power injection
        Cx=[Cx;temp_Cx];
    end
end

if isempty(z_Qinj)==0
    for i=1:length(z_Qinj)
        k=z_Qinj(i);
        temp1=real(S_calc(k));temp2=imag(S_calc(k));
        %del Q/ del theta as well as del Q/ del V
        temp_Cx(1,1:2*nob)=0;
        for j=1:nob            
            if k==j
                temp_Cx(1,k)=temp1-V(k)*V(k)*G(k,k);
                temp_Cx(1,k+nob)=(temp2-V(k)*V(k)*B(k,k))/V(k);
            else
                if connect_m(k,j)==1
                    temp_Cx(1,j)=-V(k)*V(j)*(G(k,j)*cos(Ang(k)-Ang(j))+B(k,j)*sin(Ang(k)-Ang(j)));
                    temp_Cx(1,j+nob)=V(k)*(G(k,j)*sin(Ang(k)-Ang(j))-B(k,j)*cos(Ang(k)-Ang(j)));
                end
            end
        end
        c=[c;temp2];%error vector for reactive power injection
        Cx=[Cx;temp_Cx];
    end
end

temp=Cx;
if isempty(temp)==0
    if slack==1
        Cx=temp(:,2:2*nob);
    else
        Cx=[temp(:,1:slack-1) temp(:,slack+1:2*nob)];
    end
end