ArrayValued intergral and control

2 次查看(过去 30 天)
Orongo
Orongo 2018-11-6
重新打开: madhan ravi 2018-11-8

Hi, I have a complicated integral I need to calculate. Part of the integral will be calculated with the parameter ArrayValued. My function is $\int_0^inf l(x+t) dt$ where x will take values [61,70] and function l(x) can take parameter from 61-106. My program so far looks like below, because the result is higher than expected - how can I verify the calculations is done correctly. Hence, how can I check if the integral is calculated for age up till 106?

f_AD=@(t)f_lx(age);
integral(f_AD,age,106,'ArrayValued',1)
function res=f_lx(age)
 param_1938 = [0.00005/1000,0.197642212387667/100000,1.23947876070978/10];
 param_1945 = [4.63638421052291/1000,0.0534640767171731/100000,1.37338003232635/10];
 param_1955 = [4.67255690389772/1000, 0.0192034319814117/100000, 1.47616811690684/10];
 mu_1938=@(x) f_mu(x,param_1938);
 mu_1945=@(x) f_mu(x,param_1945);
 mu_1955=@(x) f_mu(x,param_1955);
 if age>=61 && age<=69
    res = exp(-integral(mu_1955,0,age)); %(age 61-69)
 elseif age>69 && age<=76 
    res = exp(-integral(mu_1945,0,age)); %(age 70-76)
 else
    res = exp(-integral(mu_1938,0,age)); %(age 77-106)
 end
end
function res=f_mu(x,param)
 a=param(1); b=param(2); c=param(3);
 res = zeros(size(x));
 ind = x>100;
 res(ind) = a+b*exp(c*100)+(x(ind)-100)*0.001;
 res(~ind) =a+b*exp(c*x(~ind));
end
  2 个评论
Walter Roberson
Walter Roberson 2018-11-6
编辑:Walter Roberson 2018-11-6
f_AD=@(t)f_lx(age);
is wrong. It ignores the t that is input and always uses age instead, for whatever value that age happened to have at the time the function handle was created.
Your description would tend to imply
f_AD = @(t) f_lx(age+t);
but you are integrating from age to 106, and age probably already in the range 61 to 106, implying you might be passing f_lx values that are between 102 and 212, which does not sound likely to be desired.
Orongo
Orongo 2018-11-8
Walter that is so true. I have changed every step of the calculation, so the calculation is now done by the command
AD= @(x) (integral(@(t)(exp(-0.028559*t)*f_l(x+t)/f_l(x)),0,106,'ArrayValued',1));
A bit neater :) thanks for your input.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by