Integration of the unknow variable
조회 수: 1 (최근 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!