开发者

Curve fitting using a equation that involves a integral that isnt possible to solve analytically?

I'm trying 开发者_JAVA技巧from 2 days to curve fit some data that I have using this equation

f = @(x) ((x.^4) .* exp(x)) ./((exp(x)-1).^2);
gama*x + 9*R*((x/a)^3)*quad(f,0,a/x);

Here x is independent variable and a is unknown, gama is known. I tried the following procedure with the most success.

function C=myquad(a,T)
C = zeros(size(T));
gama = 20 * 1e-3;
R = 8.314;
f = @(x) ((x.^4) .* exp(x)) ./((exp(x)-1).^2);
for n = 1:length(T)
    C(n) = gama*T(n) + 9*R*((T(n)/a)^3)*quad(f,0,a/T(n));
end


>>fit(T_0,C_0,fittype('myquad(a,x)'));

It returned following error

??? NaN computed by model function, fitting cannot continue. Try using or tightening upper and lower bounds on coefficients.

Error in ==> fit at 443 errstr = handleerr( errid, errmsg, suppresserr );

No idea what to do. Please guide..


Find out why your function is returning NaN. NaN results from division of 0 by 0, or other causes.

Your function f(x) will compute 0/0 for x=0:

>> f = @(x) ((x.^4) .* exp(x)) ./((exp(x)-1).^2);
>> f(0)

ans =

   NaN

Change your limits of integration so that you don't include 0, or re-define your function f to be better behaved at 0.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜