Azzera filtri
Azzera filtri

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

3 visualizzazioni (ultimi 30 giorni)
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.!!!

Risposte (1)

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

Community Treasure Hunt

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

Start Hunting!

Translated by