Make an double integral function
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
pankaj singh
le 25 Nov 2021
Réponse apportée : Bjorn Gustavsson
le 25 Nov 2021
I want to make the double integration function (as per the formula shown in figure below) and then evaluate the integral for the given range of x and y. Please help me make the function.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/812744/image.png)
My code is something like this but gives error:
fun = @(x,y) 1/sqrt(2*pi).*exp(-x.^2/2).*exp(-1/2.*(y+(u_j-u_m)/sigma_sq)).^2);
q = integral2(fun,y,Inf,-Inf,inf);
0 commentaires
Réponse acceptée
Bjorn Gustavsson
le 25 Nov 2021
By putting the product inside the first pair of square brackets you've made the formula look a little bit confusing - since the only factors that depend on j and m_n are outside that parenthesized factor, but I'll give it a try...
The inner integral over x is just the error-function:
(erf(y/2^(1/2)) + 1)/2
This should give you a modified function, something like this:
fun = @(y) ((erf((2^(1/2)*y)/2) + 1))/2.*exp(-1/2*(y+(u_j-u_m)/s_n).^2);
Which for your desired values of u_j, u_m and s_n will integrate just fine from -inf to inf.
HTH
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Manage Products dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!