ArrayValued intergral and control
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Walter Roberson
el 6 de Nov. de 2018
Editada: Walter Roberson
el 6 de Nov. de 2018
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.
Respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!