Optimization toolbox-fmincon error-
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (2 件)
Igor
2014 年 5 月 1 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with Optimization Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!