Optimization toolbox-fmincon error-
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everybody
I'm trying to minimize a multivariable expression using fmincon under constrain. To introduce you more precisely the problem. I want to find the normal vector u of the best fitting plan which describe the most precisely a set of data from a marker placed on a rat knee. And for this I use an optimization method. But it doesn't work... My matlab version is R2012b
The expression to minimize is:
function [f] = Functiofun(S)
syms x y z
u=[x;y;z];
f=u'*S*u;
end
were S is a matrix using data of the marker and this returns:
f =
x*((4919489910730857*conj(x))/549755813888 + (1885243380871159*conj(y))/274877906944 - (1356072232583407*conj(z))/549755813888) - z*((1356072232583407*conj(x))/549755813888 + (4128876282184185*conj(y))/2199023255552 - (3333614421791133*conj(z))/137438953472) + y*((1885243380871159*conj(x))/274877906944 + (924159128957421*conj(y))/68719476736 - (4128876282184185*conj(z))/2199023255552)
Hence I want to minimize this function under the following constrain:
function [g] = Functionfun_g(C)
syms x y z
u=[x;y;z];
g=u'*C*u-1;
end
which is simply normalisation of my output vector
g =
x*conj(x) + y*conj(y) + z*conj(z) - 1
so I wrote the following code sentence using fmincon:
x0=[0;0;0]
options = optimset('Algorithm','sqp');
[x,fval] = fmincon(f,x0,[],[],[],[],[],[],...
g,options);
And it returns me this error:
Error using optimfcnchk (line 288)
If FUN is a MATLAB object, it must have an feval method.
Error in fmincon (line 423)
funfcn =
optimfcnchk(FUN,'fmincon',length(varargin),funValCheck,flags.grad,flags.hess,false,Algorithm);
.... I need help please :)
0 Kommentare
Antworten (2)
Igor
am 1 Mai 2014
You can't pass symbolic variables as functions to 'fmincon'. Use 'matlabFunction' to convert your symbolic functions to function handles: http://www.mathworks.com/help/symbolic/matlabfunction.html
Good luck
0 Kommentare
Siehe auch
Kategorien
Mehr zu Get Started with Optimization Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!