Integration of the unknow variable

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

Respuestas (2)

Sean de Wolski
Sean de Wolski el 11 de Oct. de 2013
You have the inputs to int backwards:
G = int(f,x,0,inf)

2 comentarios

Jamal Ahmad
Jamal Ahmad el 11 de Oct. de 2013
Thank you very much for the answer. But I have this warning:
Warning: Explicit integral could not be found.
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

Iniciar sesión para comentar.

sixwwwwww
sixwwwwww el 11 de Oct. de 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 comentarios

Jamal Ahmad
Jamal Ahmad el 11 de Oct. de 2013
Thanks for the answers. but still my integration has not been computed. do you know how to compute this kind of integration that contain error function? thanks
sixwwwwww
sixwwwwww el 11 de Oct. de 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
sixwwwwww el 11 de Oct. de 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

Iniciar sesión para comentar.

Preguntada:

el 11 de Oct. de 2013

Comentada:

el 11 de Oct. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by