Undefined function or variable
조회 수: 1 (최근 30일)
이전 댓글 표시
Here is my code:
global ZX1 ZX3 ZX3
[Z,fval, exitflag] = fmincon('Type1',x0,[],[],[],[],lb,ub,@myconT1,options)
function f=Type1(d)
a=1;
b=0;
g=0;
f=(1+d1())^a+(1+d2())^b+(1+d3())^g;
end
function [c,ceq,d] = myconT1(X,d)
global xn V ZX1 ZX3 ZX4
c=0;
ceq(1)=(X'*V*X)-1;
xn=1-sum(X)
ceq(2)=sum(X)+xn-1;
ceq(3)=X'*R+0.33*xn+d1()-ZX1;
ceq(4)=mean((X'*(R-mean(R)))^3)+d3()-ZX3;
ceq(5)=-mean((X'*(R-mean(R)))^4)+d4()+ZX4;
end
It's note all my code. Error message:
Undefined function or variable 'd1'.
Error in Type1 (line 5) f=(1+d1())^a+(1+d2())^b+(1+d3())^g;
Error in fmincon (line 635) initVals.f = feval(funfcn{3},X,varargin{:});
Error in TP (line 158) [Z,fval, exitflag] = fmincon('Type1',x0,[],[],[],[],lb,ub,@myconT1,options)
Caused by: Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.
Any idea?
Thank you
댓글 수: 1
dpb
2014년 4월 9일
Clearly it's not all the code because didn't even put in what is in context of the error message --
Undefined function or variable 'd1'.
Error in Type1 (line 5) f=(1+d1())^a+(1+d2())^b+(1+d3())^g;
Your problem is that in the above line there is no d1 in context. You need that definition first. One then presumes you'll move on to d2 and d3 in turn.
What are these intended to be and what are the empty paren's trying to indicate? If the various d are functions w/ no arguments then the () are superfluous and if they're arrays they're missing a subscript expression.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!