How to calculate the integral of a function with a spline in it
33 ビュー (過去 30 日間)
古いコメントを表示
Hello Everybody,
So i have a function called FB, and it is the product of a couple of functions
nB = spline(Wavelength,B3);
emi = @(x) 1.989e-6*(10^9*x).^2-0.002;
FB = @(x,T) nB(x).*emi(x)./(x.^5.*(exp((h.*c)./(x.*k.*T))-1))
%integration:
RaBG(Counts) = integral(@(x)FB(x,T),400e-9,720e-9)
nB is a function i must adquire from data. When fitting it with a polinomial function i get a small error which i believe is making me get wrong results, though the code works. I'm trying to fit it with a spline but haven't been able to get the code to work. I also tryied calling FB as this, which didn't work:
FB = @(x,T) ppval(nB,x).*emi(x)./(x.^5.*(exp((h.*c)./(x.*k.*T))-1));
Can anyone please help me?
3 件のコメント
John D'Errico
2017 年 4 月 25 日
I'd like to chime in here,but without knowing what wavelength, B3, and G3 are, it is impossible to give a useful answer.
回答 (1 件)
Andrew Newell
2017 年 4 月 24 日
編集済み: Andrew Newell
2017 年 4 月 24 日
Interpolation is also reasonable. How exactly isn't the code working?
I don't see any values assigned to c, k or T. Are you doing that earlier? If so, it would make sense to define
FB = @(x) ppval(nB,x).*emi(x)./(x.^5.* (exp((h.*c)./(x.*k.*T))-1));
7 件のコメント
参考
カテゴリ
Help Center および File Exchange で Splines についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!