how to optimize the integral function?
Mostra commenti meno recenti
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)
Risposte (1)
Alan Weiss
il 18 Apr 2013
0 voti
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
Categorie
Scopri di più su Problem-Based Optimization Setup in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!