Solving a nonlinear equation with numerical integration
古いコメントを表示
Hello everybody,
I am pretty new in Matlab and struggling at the moment. I want to calculate two unknown parameters (x1 and x2) from two equations with integrals inside.

The Values P1, P2, S1, S2, C1, C2 are known and have the datatype double.
B(lambda) and e(lambda) are datasets (x,y) stored in arrays that describe the filter curves (also double).
Many thanks for your help.
回答 (1 件)
First method:
1. Fit functions B1(lambda), B2(lambda), e1(lambda) and e2(lambda) to your data in the different ranges (500 to 550 and 600 to 650).
2. Call fsolve as
fun = @(x)[P1-S1*integral(@(lambda)B1(lambda).*e1(lambda).*(1-exp(-x(1)./lambda.^1.39)).*c1./(lambda.^5.*(exp(c2./(lambda*x(2)))-1)),500,550),P2-S2*integral(@(lambda)B2(lambda).*e2(lambda).*(1-exp(-x(1)./lambda.^1.39)).*c1./(lambda.^5.*(exp(c2./(lambda*x(2)))-1)),600,650)];
x0 = [1, 1];
xsol = fsolve(fun,x0)
Second method:
function main
S1 = ...;
S2 = ...;
P1 = ...;
P2 = ...;
l = ...;
e = ...;
B = ...;
x0 = [1, 1];
xsol = fsolve(@(x)fun(x,S1,S2,P1,P2,l,e,B),x0);
function res = fun(x,S1,S2,P1,P2,l,e,B)
interpe = @(lambda)interp1(l,e,lambda);
interpB = @(lambda)interp1(l,B,lambda);
funI = @(lambda)interpe(lambda).*interpB(lambda).*(1-exp(-x(1)./lambda.^1.39)).*c1./(lambda.^5.*(exp(c2./(lambda*x(2)))-1));
res = [P1-S1*integral(funI,500,550),P2-S2*integral(funI,600,650)];
Best wishes
Torsten.
10 件のコメント
Michael Bond
2017 年 11 月 30 日
Torsten
2017 年 11 月 30 日
You will need a rootfinder.
If you can't make fsolve run, you will have to program a simple newton method on your own or get code from the file exchange.
Best wishes
Torsten.
Torsten
2017 年 12 月 1 日
Another possibility is to use "fminsearch" instead of "fsolve" for your problem:
function main
S1 = ...;
S2 = ...;
P1 = ...;
P2 = ...;
l = ...;
e = ...;
B = ...;
x0 = [1, 1];
xsol = fminsearch(@(x)fun(x,S1,S2,P1,P2,l,e,B),x0);
function res = fun(x,S1,S2,P1,P2,l,e,B)
interpe = @(lambda)interp1(l,e,lambda);
interpB = @(lambda)interp1(l,B,lambda);
funI = @(lambda)interpe(lambda).*interpB(lambda).*(1-exp(-x(1)./lambda.^1.39)).*c1./(lambda.^5.*(exp(c2./(lambda*x(2)))-1));
res = (P1-S1*integral(funI,500,550))^2+(P2-S2*integral(funI,600,650))^2;
Michael Bond
2017 年 12 月 1 日
編集済み: Michael Bond
2017 年 12 月 1 日
Michael Bond
2017 年 12 月 1 日
Delete the semicolon after
xsol = fsolve(@(x)fun(x,S1,S2,P1,P2,l,e,B),x0);
But note that the lists of variables transferred to "fun" don't agree:
B becomes B1,B2.
Read again what l, e and B have to contain in my notation.
Best wishes
Torsten.
Michael Bond
2017 年 12 月 1 日
Remove the two "end" statements in your code.
Remove the semicolon after
function res = fun(x,S1,S2,P1,P2,l,e,B1,B2);
Best wishes
Torsten.
Michael Bond
2017 年 12 月 1 日
カテゴリ
ヘルプ センター および File Exchange で Univariate Discrete Distributions についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!