필터 지우기
필터 지우기

ERROR: FMINCON requires all values returned by functions to be of data type double.

조회 수: 3 (최근 30일)
This is the main running code, once started will always report this error.
Func is my object function.
Func = @(x) WW_Period_Sum(x);
options = optimoptions('fmincon','Display','iter');
nonlcon = [];%@myConstraintFunction;
a = fmincon(Func, x0, [], [], [], [], [], [], nonlcon, options);%x0 is already assigned.
Unrecognized function or variable 'x0'.
I have this nonlcon function. ce and ceq are all array of cells about x
function [ce, ceq] = myConstraintFunction(x)
ce = @(x) ineq_temp;
ceq = @(x) eq_temp;
end
H is a matrix, and I'm trying to find its Condition Number.
function cond_value = calcCond(x,t);
cond_value = @(x,t) cond(H);
end
Sum of all values within 0.01s.
function WW_period = WW_Period_Sum (x);
WW_period_=@(x) 0;
for t=0:0.002:0.01
cond_temp = @(x) calcCond(x, t);
WW_period_ = @(x) WW_period_(x) + cond_temp(x);
end
WW_period = WW_period_;
end
And Keep reporting errors "Error using fmincon (line 19)
FMINCON requires all values returned by functions to be of data type double."
Thanks for giving me a lift to the station.!!!

답변 (1개)

Walter Roberson
Walter Roberson 2023년 11월 16일
WW_period_=@(x) 0;
You are returning a function handle. You need to return a scalar numeric value instead.

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by