how to optimize the integral function?
Mostrar comentarios más antiguos
function F =t(x)
syms e
k=1:511;
F=int((abs(sinc(x*(k+e)))).^2/(abs(sinc(x*e))).^2,e,0,1);
[x,resnorm]=lsqnonlin(@t,0,0,1);
i want to optimize the function 'F' and parameter is 'x' when i run the program error occurred:
Undefined function or method 'isfinite' for input arguments of type 'sym'.
Error in ==> snls at 45 if any(~isfinite(fval))
Error in ==> lsqncommon at 149 [xC,FVAL,LAMBDA,JACOB,EXITFLAG,OUTPUT,msgData]=...
Error in ==> lsqnonlin at 238 [xCurrent,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...
Error in ==> l at 2 [x,resnorm]=lsqnonlin(@t,0,0,1)
Respuestas (1)
Alan Weiss
el 18 de Abr. de 2013
0 votos
You have several problems in your code.
- Optimization Toolbox uses doubles, not symbolic variables.
- Your function seems to be calling itself (lsqnonlin(@t... occurs inside the definition of t as far as I can see)
To convert from symbolic to numeric, use subs, or the much faster matlabFunction. See this example or this example.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
Categorías
Más información sobre Problem-Based Optimization Setup en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!