ERROR: FMINCON requires all values returned by functions to be of data type double.
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
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.!!!
0 commentaires
Réponses (1)
Walter Roberson
le 16 Nov 2023
WW_period_=@(x) 0;
You are returning a function handle. You need to return a scalar numeric value instead.
0 commentaires
Voir également
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!