Integration of the unknow variable
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, Is it possible in MatLab to integrate a function of the unkow variable? for example:
clc; clear all; close all;
syms a b f g x
f = erfc(sqrt((x)/2))*(1./g)*exp(-(x/g));
g = int(f,0,inf,x);
How I can do this integration?
Thank you
0 commentaires
Réponses (2)
Sean de Wolski
le 11 Oct 2013
You have the inputs to int backwards:
G = int(f,x,0,inf)
2 commentaires
Sean de Wolski
le 11 Oct 2013
This implies that there is not an explicit integral for this. Instead, you might want to consider calculating the integral numerically using integral
doc integral
sixwwwwww
le 11 Oct 2013
Dear Jamal Ahmad, You are using "int" in wrong format. See http://www.mathworks.com/help/symbolic/int.html
g = int(f,0,inf,x);
It should be used in its proper form with proper sequence of input arguments as:
int(expr,var,a,b)
So the corrected code is:
syms f g x
f = erfc(sqrt((x)/2))*(1./g)*exp(-(x/g));
Integration_result = int(f,x,0,Inf)
Here arguments x, 0 and Inf are placed rightly. Good luck!
3 commentaires
sixwwwwww
le 11 Oct 2013
Basically, error functions is like other functions so it can be integrated in the same way as other functions are integrated. I have integrated your function and got the following result using the code given above in my ans.
Integration_result = int((exp(-x/g)*erfc((x/2)^(1/2)))/g, x == 0..Inf)
So the integration is already performed. It did get any numerical value as result because we don't know the value of symbol "g". Now if you replace g with some numeric value then you will get the integration result. For example, if you replace "g" with value 2 then you can get numerical result. I hope it ans your question. If you need code doing this then let me know I will post it
sixwwwwww
le 11 Oct 2013
Dear Jamal, for your convenience here is the final code:
syms f g x % Your symbolic variables
f = erfc(sqrt((x)/2))*(1./g)*exp(-(x/g)); % Your function to be integrated
f_new = subs(f, g, 2); % replacing "g" with value 2 in function "f"
Integration_result = double(int(f_new,x,0,Inf)) % Getting final integration ans
Voir également
Catégories
En savoir plus sur Calculus 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!