Integration with both limits variable
Afficher commentaires plus anciens
Hi, I am trying to solve an integration where both limits are variable. The function itself being integrated is simple, it is just exp(-W^2). I can solve the inegration fine using this method without limits - the limits are the issue here. I think it could be because of the use of the symbolic functions to integrate? But I have tried other methods, and I cannot get it to work with these limits. I get the error:
error in sym/subsref (line 898)
R_tilde = builtin('subsref',L_tilde,Idx);
The upper limit is -phi, and the lower limit is beta-phi.
Another issue could be because the upper limit is the same as the variable being integrated. However I don't know how to get around that issue either?
I have just shown some of my code, hopefully this is enough to make sense of what I am trying to do. Any help would be greatly appreciated!
t=linspace(0,1000);
r=linspace(0,100);
D=2;
beta=r./sqrt(4*D.*t);
phi=U.*sqrt(t./D);
W=beta-phi;
% Performing integration
syms W
f=exp(-(W.^2));
a=-phi;
b=beta-phi;
int(f,W,a,b)
3 commentaires
Bjorn Gustavsson
le 19 Sep 2020
Use the error-function, erf, and then you're done - if this is your full problem...
Sophie Malcolm
le 20 Sep 2020
Bjorn Gustavsson
le 20 Sep 2020
Your solution is simply:
(pi^(1/2)*(erf(b) - erf(a)))/2.
Réponse acceptée
Plus de réponses (1)
Bjorn Gustavsson
le 19 Sep 2020
0 votes
Matlab has both a numerical and a symbolic version of the error-function. That will be the answer to your problem. The numeric version is vectorized, so it can handle your inputs without problems.
HTH
1 commentaire
Sophie Malcolm
le 20 Sep 2020
Catégories
En savoir plus sur MATLAB 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!