function [C0,C1] = optControllerParamrs(delPhi,alphaMin,betaMax,phizMin,phizMax,type)
% C0,C1 = [alpha beta phiz]

%   Copyright 2014-2020 The MathWorks, Inc.

switch type
    case 'Z2P' % Z2P: betaMax > phizMax, alphaMin > phizMin
        MD = (alphaMin+betaMax)/2;
        A0 = [MD MD phizMin;MD MD-eps(MD) MD;alphaMin MD+eps(MD) alphaMin;alphaMin MD MD;alphaMin phizMax phizMax;alphaMin betaMax phizMax];
        A1 = [MD MD phizMin;MD betaMax phizMin;alphaMin betaMax phizMin;alphaMin betaMax-eps(betaMax) alphaMin;MD betaMax+eps(betaMax) MD;MD betaMax phizMax;alphaMin betaMax phizMax];
        C0 = interp1(A0*[-1;1;1],A0,delPhi);
        C1 = interp1(A1*[-1;1;1],A1,delPhi);
    case 'Z2' % Z2: (beta,phiz) -> (phi1,phi2), alpha = 0
        A0 = [0 phizMin phizMin;0 phizMax phizMax];
        A1 = [0 phizMin phizMin; 0 phizMin phizMax;0 phizMax phizMax];
        C0 = interp1(A0*[-1;1;1],A0,delPhi);
        C1 = interp1(A1*[-1;1;1],A1,delPhi);
    case 'ZP' % ZP: phiz = 0;
        MD = (alphaMin+betaMax)/2;
        A0 = [MD MD 0;alphaMin MD 0;alphaMin betaMax 0];
        A1 = [MD MD 0;MD betaMax 0;alphaMin betaMax 0];
        C0 = interp1(A0*[-1;1;1],A0,delPhi);
        C1 = interp1(A1*[-1;1;1],A1,delPhi);
    case 'Z' % Z: alpha = beta = 0;
        C0 = [0 0 interp1([phizMin;phizMax],[phizMin;phizMax],delPhi)];
        C1 = C0;
end
