fmincon after solve error
이전 댓글 표시
I'm having some problem using fmincon. I have three variables:
var(1) = sym('pilotPower');
var(2) = sym('dataPower');
gamma = sym('gamma');
With the vpasolve I solve the equation in function of gamma so fun has two variable var(1) and var(2). Then I take one of the solution and I put it in fmincon after the conversion in a Matlab function (if I don't do that I receive a different error).
These are the constraints:
% Starting evaluation point for fmin con
x0 = [1,249];
% pilotPower + dataPower <= powerBudgetLin
A = [1,1];
b = powerBudgetLin;
And this is the remaining part of the code
eqn = usersNum*alpha^2*var(2)*q+dataSigma2 ==...
receiversNum*alpha^2*var(2)*d/gamma-(usersNum 1)*alpha^2*var(2)*d/(1+gamma);
fun = -vpasolve(eqn,gamma);
myMatlabFunction = matlabFunction(fun(1));
[pilotPowerOpt,fval] = fmincon(myMatlabFunction,x0,A,b);
If I inspect myMatlabFunction I see that it has two variable "pilotPower" and "dataPower"
At the moment I have as a error "Not enough input arguments. Error in optimizationtest (line 106) [pilotPowerOpt,fval] = fmincon(myMatlabFunction,x0,A,b); Caused by: Failure in initial objective function evaluation. FMINCON cannot continue. "
My aim is to maximize the positive result of "fun".
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Nonlinear Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!