how to optimize the integral function?
Afficher commentaires plus anciens
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)
Réponses (1)
Alan Weiss
le 18 Avr 2013
0 votes
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
Catégories
En savoir plus sur Problem-Based Optimization Setup dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!