フィルターのクリア

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

3 ビュー (過去 30 日間)
Siwei Luo
Siwei Luo 2023 年 11 月 16 日
回答済み: Walter Roberson 2023 年 11 月 16 日
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 Center および File ExchangeSolver 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