필터 지우기
필터 지우기

Find the theta1 and theta2 values that maximize the function

조회 수: 2 (최근 30일)
Andreas S
Andreas S 2020년 10월 10일
댓글: Andreas S 2020년 10월 10일
Hi everyone! Im trying to maximize this equation by finding those theta1 and theta2:
obj8Run = @(theta) -mean(sum((1+theta1.*csecxit+theta2.*csecyit)/N.*R4-c*t4,2))./sqrt(sum((1+theta1.*csecxit+theta2.*csecyit)/N.*R4-c*t4,2))
w0 = [0.2,0.3] % initial guess
lb = zeros(1, 2)
ub = 1.5*ones(1, 2)
sol = fmincon(obj8Run, w0, [], [], [], [], lb, ub)
Matlab gives me this error problem: Error using fmincon (line 635) .Supplied objective function must return a scalar value.
Can someone help me?
Thanks in advance!!!

답변 (1개)

madhan ravi
madhan ravi 2020년 10월 10일
obj8Run = @(theta) -mean(sum((1+theta(1).*csecxit+theta(2).*csecyit)/N.*R4-c*t4,2))./sqrt(sum((1+theta(1).*csecxit+theta(2).*csecyit)/N.*R4-c*t4,2))
  댓글 수: 1
Andreas S
Andreas S 2020년 10월 10일
Hello! Thanks for your reply, first of all. When i run:
obj8Run = @(theta) -mean(sum((1+theta1.*csecxit+theta2.*csecyit)/N).*R4-c*t4,2)./sqrt(sum((1+theta1.*csecxit+theta2.*csecyit)/N).*R4-c.*t4,2)
w0 = [0.2,0.3] % initial guess
lb = zeros(1, 2)
ub = 1.5*ones(1, 2)
sol = fmincon(obj8Run, w0, [], [], [], [], lb, ub)
it gives me : Error using sqrt
Too many input arguments.
Error in @(theta)-mean(sum((1+theta1.*csecxit+theta2.*csecyit)/N).*R4-c*t4,2)./sqrt(sum((1+theta1.*csecxit+theta2.*csecyit)/N).*R4-c.*t4,2)
Error in fmincon (line 562)
initVals.f = feval(funfcn{3},X,varargin{:});
Caused by:
Failure in initial objective function evaluation. FMINCON cannot continue.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by