Integration of the unknow variable
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Sean de Wolski
2013-10-11
You have the inputs to int backwards:
G = int(f,x,0,inf)
2 个评论
Sean de Wolski
2013-10-11
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
2013-10-11
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 个评论
sixwwwwww
2013-10-11
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
2013-10-11
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!