how to optimize the integral function?

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)

回答 (1 件)

Alan Weiss
Alan Weiss 2013 年 4 月 18 日

0 投票

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

カテゴリ

ヘルプ センター および File ExchangeProblem-Based Optimization Setup についてさらに検索

タグ

質問済み:

2013 年 4 月 18 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by