Integration of the unknow variable

1 回表示 (過去 30 日間)
Jamal Ahmad
Jamal Ahmad 2013 年 10 月 11 日
コメント済み: sixwwwwww 2013 年 10 月 11 日
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

回答 (2 件)

Sean de Wolski
Sean de Wolski 2013 年 10 月 11 日
You have the inputs to int backwards:
G = int(f,x,0,inf)
  2 件のコメント
Jamal Ahmad
Jamal Ahmad 2013 年 10 月 11 日
Thank you very much for the answer. But I have this warning:
Warning: Explicit integral could not be found.
Sean de Wolski
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
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
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
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 ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by