Problem with undefined variable in integral
Afficher commentaires plus anciens
Hi, I try to solve this integral:

where the functions in lambda are defined in the code. I try want to compute this integral for several values of a like 18,19, and so on. I first tried with a=18 then i compute (without success) pi(18). Here is my code:
if true
cms = @(s) exp(1.39-0.065*s);
cfu = @(u) exp(0.83-0.071*u);
Ifu = @(u) exp(-0.970774-0.077159*u);
sdu = @(u) (-0.67+0.133*u);
mu = @(u) (u-4)/0.8;
pm = @(u,s) (1/sqrt(2*pi*(sdu(u)^2)))*exp(-(1/2*sdu(u)^2)*(s-mu(u))^2);
lambdas = @(s) cms(s)*integral((cfu(u)*Ifu(u)*@(u)pm(u,s)),18,65);
%%%%
cmu = @(u) exp(1.39-0.065*u);
cfr = @(r) exp(0.83-0.071*r);
Ifr = @(r) exp(-0.970774-0.077159*r);
sdr = @(r) (-0.67+0.133*r);
mr= @(r) (r-4)/0.8;
%%%%
pm = @(r,u) (1/sqrt(2*pi*(sdr(r))^2))*exp(-(1/2*sdr(r)^2)*(u-mr(r))^2);
lambdau = @(u) cmu(u)*integral((cfr(r)*Ifr(r)*@(r)pm(r,u)),18,65);
%Try to compute pi for a=20 pi(20)
integral(exp(20-s)*lambdas(s)*exp(-integral(lambdau(u),18,s)),18,20) ;
end
I always get this error : Undefined function or variable 's'.
Any suggestion to correct it? Sorry but I'm quite new to matlab.. maybe I'm doing a really silly mistake.
Réponses (1)
Walter Roberson
le 28 Jan 2016
integral( @(s) exp(20-s)*lambdas(s)*exp(-integral(@(u) lambdau(u),18,s)),18,20) ;
1 commentaire
Martina
le 28 Jan 2016
Catégories
En savoir plus sur Plot Settings dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!