Nested integral and how to plot
Show older comments
Hi, I have this exercise to calculate D_x that is defined as following:

So far my program looks like this..
main.m:
% main.m
delta = 0.028559;
x=61;
mu_x=@(t) mu(t);
lx = @(x) exp(-integral(@(t) mu_x(t),0,x));
Dx = integral(@(t) exp(-delta*t)*lx(x+t)/lx(x), 0, inf,'ArrayValued', true);
mu.m
function res=mu(x)
a=0.006782872;
b=5.44781E-08;
c=0.137849468;
res = zeros(size(x));
ind = x>97;
res(~ind) = a+b*exp(c*x(~ind));
res(ind) = a+b*exp(c*97)+(x(ind)-97)*0.001;
end
There are 2 main questions I struggle with this one. 1) Is the program correct? I get a higher value then expected and I don't understand how Matlab assign integrals. 2) How to I plot the results? Say x=61:101 for mu_x, l(x) and D_x?
Answers (0)
Categories
Find more on Numerical Integration and Differentiation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!