NONLCON must be a function.
Error in fmincon (line 409)
confcn = optimfcnchk(NONLCON,'fmincon',length(varargin),funValCheck,flags.gradconst,false,true);
nAssets = size(ExpCovariance,2);
options = optimoptions(@fmincon,'Algorithm','interior-point');
nFrontierPts = 20;
pWts = zeros(nFrontierPts, nAssets);
pExitFlag = zeros(nFrontierPts, 1);
StaticFXhedgeReturns = AssetReturns(t-59:t,1)+AssetReturns(t-59:t,2:7)*exp1';
StaticVol5y = std(StaticFXhedgeReturns)*sqrt(12);
StaticTE5y = std(AssetReturns(t-59:t,2:7)*exp1')*sqrt(12);
teCap=StaticTE5y;
covMat=cov(equRet(t-2-59:t-2),AssetReturns(t-59:t,2:7)*exp1')*12;
covCap=covMat(1,2);
iniWt = ones(1,nAssets).*(1/nAssets);
Aud6040ret = AssetReturns(t-x-59:t-x,1);
FXret_1 = AssetReturns(t-x-59:t-x,2:7);
equRet_1 = equRet(t-59-2:t-2);
minVarWts = fmincon(@(pWts) -pWts*ExpCovariance'*pWts', iniWt, [], [], [], [],...
LowerBound', UpperBound',nonlconFr(pWts,StaticVol5y,teCap,Aud6040ret,FXret_1,equRet_1,covCap), options);
function [c, ceq] = nonlconFr(w,volcap,teCap,Aud6040ret,FXret,equRet,covCap)
w = w(2:7)';
ret_w = Aud6040ret+FXret*w;
covMat=cov(equRet,FXret*w)*12;
c(1) = std(ret_w)*sqrt(12) - volcap;
c(2) = std(FXret*w)*sqrt(12) - teCap;
c(3) = covMat(1,2) - covCap;
ceq = [];
end