Passing xtra parameter
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i do an example provide in matlab on passing xtra parameter. these are the codes:
function y = parameterfun(x,a,b,c)
a = 4; b = 2.1; c = 4; % Assign parameter values
x0 = [0.5,0.5];
y = (a - b*x(1)^2 + x(1)^4/3)*x(1)^2 + x(1)*x(2) +(-c + c*x(2)^2)*x(2)^2;
f = @(x)parameterfun(x,a,b,c);
[x,fval] = fminunc(f,x0)
end
However, i got an error said that:
??? Input argument "x" is undefined.
Error in ==> parameterfun at 4
y = (a - b*x(1)^2 + x(1)^4/3)*x(1)^2 + x(1)*x(2) +(-c + c*x(2)^2)*x(2)^2;
please help me. I dont know how to fix it. tq
0 commentaires
Réponses (1)
Geoff
le 24 Fév 2012
That doesn't look right. I am guessing you intended to do the following:
function y = parameterfun(x,a,b,c)
y = (a - b*x(1)^2 + x(1)^4/3)*x(1)^2 + x(1)*x(2) +(-c + c*x(2)^2)*x(2)^2;
end
a = 4; b = 2.1; c = 4; % Assign parameter values
x0 = [0.5,0.5];
f = @(x)parameterfun(x,a,b,c);
[x,fval] = fminunc(f,x0)
Voir également
Catégories
En savoir plus sur Logical 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!