필터 지우기
필터 지우기

Integral calling another integral

조회 수: 2 (최근 30일)
Orongo
Orongo 2018년 11월 4일
댓글: Star Strider 2018년 11월 4일
Hi I get an error when calculating an integral. The error is caused by my "nested" integral. Here is what I have written so far and running it show you an error after the calculation of f_lx. How can I have this running?
age=61;
f_AD=@(t) f_lx(t,age);
AD(age,1)=integral(f_AD,age,106);
function res=f_lx(t,age)
param_1955 = [4.67255690389772/1000, 0.0192034319814117/100000, 1.47616811690684/10];
mu_1955=@(x) f_mu(x,param_1955); % my error appears here
res = exp(-integral(mu_1955,0,age));
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

채택된 답변

Star Strider
Star Strider 2018년 11월 4일
Change your ‘AD’ assignment to:
AD(age,1)=integral(f_AD,age,106, 'ArrayValued',1);
  댓글 수: 2
Orongo
Orongo 2018년 11월 4일
Thanks, works brilliantly.
Star Strider
Star Strider 2018년 11월 4일
As always, my pleasure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by