I want use Simpson numerical integration method

조회 수: 1 (최근 30일)
Soonyoung Cha
Soonyoung Cha 2013년 6월 6일
I try to integral below function. But it makes some error when I try.
syms x, T, Ef, k
Q = x.^k/(1+exp(-(x-Ef)/T));
int ( Q, x, 0.2, 1);
it makes error they cannot find something.
------------------------------------------------
Finally, I want to make below function
Function [K] = ff(a,b,c);
k=a; Ef =b, T = c;
Q = x.^k/(1+exp(-(x-Ef)/T));
k = int ( Q, x, 0.2, 1);
Also, if it is possible, numerical integral method is fine for me. I think I can use Simpson numerical integration but please give me some hints to use it.
Thank you!

채택된 답변

Andrew Newell
Andrew Newell 2013년 6월 6일
편집: Andrew Newell 2013년 6월 6일
If you want your integral to be a function of all the parameters, you could define the following:
function y = fintegral(k,Ef,T,lb,ub)
f = @(x) x.^k./(1+exp(-(x-Ef)/T));
y = quadl ( f, lb, ub);
Then a typical call would look like this:
k = 1; Ef = 2; T = 3; lb = 0.2; ub = 1;
fintegral(k,Ef,T,lb,ub)
ans =
0.1884

추가 답변 (1개)

Roger Stafford
Roger Stafford 2013년 6월 6일
편집: Roger Stafford 2013년 6월 6일
The 'int' function probably could not find an explicit formula for the integral of Q in terms of general k, Ef, and T variables. That is easy to happen even for relatively simple integrands.
Since you possess a formula for your integrand, I see no need for using the Simpson method which uses a fixed discrete set of data. It would be better to use one of the numerical quadrature functions, preferably the new 'integral' function. Bear in mind that to do, so you need to provide specific numerical values to each of the parameters, k, Ef, and T (a, b, and c) for each value of Q you calculate.
Note that you can reduce your problem to two parameters:
Q(x;k,Ef,T) = T^k * y^k/(1+exp(y-k2))
where y = x/T and k2 - Ef/T, so that you would have only the two parameters k and k2 to contend with in the integration process.
  댓글 수: 1
Soonyoung Cha
Soonyoung Cha 2013년 6월 7일
Thank you for your help!! I will try this way for another problem

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by