I have made some revision on the code
--
col_myfun = @(x, w) (x'*(w(1)*B+w(2)*eye(size(B,1)))*x);
x = fmincon(@(x, w) col_myfun,[zeros(size(B,1),1);0.5;0.5],[],[],[-C' zeros(1,2);zeros(1,length(C)) ones(1,2)],[c_star;1],[-inf*ones(size(B,1),1);zeros(2,1)],[])
--
But still met the error message
--
??? Undefined function or method 'minus' for
input arguments of type 'function_handle'.
Error in ==> finitedifferences at 200
gradf(gcnt,1) =
(fplus-fCurrent)/CHG(gcnt);
Error in ==> nlconst at 286
[gf,gnc,NEWLAMBDA,OLDLAMBDA,s]=finitedifferences(XOUT,x,funfcn,confcn,lb,ub,f,nc,
...
Error in ==> fmincon at 562
[X,FVAL,lambda,EXITFLAG,OUTPUT,GRAD,HESSIAN]=...
Error in ==> collinearity_mop at 64
x = fmincon(@(x, w)
col_myfun,[zeros(size(B,1),1);0.5;0.5],[],[],[-C'
zeros(1,2);zeros(1,length(C))
ones(1,2)],[c_star;1],[-inf*ones(size(B,1),1);zeros(2,1)],[])
--
What's gone wrong? Thanks a lot.