How to use fsolve to solve the simultaneous equations with integral format?

3 ビュー (過去 30 日間)
Louis Liu
Louis Liu 2017 年 9 月 10 日
コメント済み: Louis Liu 2017 年 9 月 10 日
Hello, I am try to solve the simultaneous equations with integrand recently, but I am stuck now, below is the detail:
The simultaneous equations that I want to solve:
and I write some code like this:
kursi = 1; b1 = 3*1.33+1; b2 = 3*1+1; alpha = 0.05; beta = 0.10;
fun1 = @(t,c0,n) chi2cdf( (n-1)*(b1*sqrt(n)-t).^2./(9*n*c0.^2),n-1 )...
*( normpdf(t+kursi*sqrt(n))+normpdf(t-kursi*sqrt(n)) );
fun2 = @(t,c0,n) chi2cdf( (n-1)*(b2*sqrt(n)-t).^2./(9*n*c0.^2),n-1 )...
*( normpdf(t+kursi*sqrt(n))+normpdf(t-kursi*sqrt(n)) );
eq = @(c0,n) [ integral( @(t)fun1(t,c0,n),0,b1*sqrt(n) )-(1-alpha);...
integral( @(t)fun2(t,c0,n),0,b2*sqrt(n) )-beta ];
result = fsolve(eq,[0,100]);
the feedback from Matlab:
Not enough input arguments.
Error in
@(c0,n)[integral(@(t)fun1(t,c0,n),0,b1*sqrt(n))-(1-alpha);integral(@(t)fun2(t,c0,n),0,b2*sqrt(n))-beta]
Error in fsolve (line 230)
fuser = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.
===================================================================== After comparing to the doc fsolve, I guess the problem are function handle and integral. Does anyone can give me some advices? Thanks!

採用された回答

Matt J
Matt J 2017 年 9 月 10 日
編集済み: Matt J 2017 年 9 月 10 日
The problem is in the way your are passing the unknown input parameters. It should be as a single unknown vector,
result = fsolve(@(p) eq(p(1),p(2)) ,[0,100]);
I would also mention that if p(2)=n is meant to be a discrete variable, fsolve will not handle that. It treats all unknowns as continuous variables.
  5 件のコメント
Matt J
Matt J 2017 年 9 月 10 日
It is the starting point.
Louis Liu
Louis Liu 2017 年 9 月 10 日
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by