How to calculate integral of a function ?

2 ビュー (過去 30 日間)
Captain Singh
Captain Singh 2014 年 8 月 5 日
コメント済み: Captain Singh 2014 年 8 月 6 日
Hello Friends, I am new for matlab, I want to calculate a integral but I don't know, how should I do it exactly. My matlab code is here:
_________________________________________________________________________________________________
clear all;
format long;
T = 0.6;
m = 3.00;
kmin = 1.0;
kmax = 10.0;
fun = @(k) k.^2/exp(sqrt(k.^2 + m.^2)/T) + 1;
q = int (fun,kmin,kmax);
_________________________________________________________________________________________________
When I execute the program I got error message:
*??? Undefined function or
method 'int' for input
arguments of type
'function_handle'.
Error in ==> nudenNccbar at 14
q = int (fun,kmin,kmax);*_ *
Please help me to short out the problem. Thank you.

採用された回答

Michael Haderlein
Michael Haderlein 2014 年 8 月 6 日
編集済み: Michael Haderlein 2014 年 8 月 6 日
The function is quad, quadl, or quadgk:
fun = @(k) k.^2./exp(sqrt(k.^2 + m.^2)/T) + 1;
quad(fun,kmin,kmax)
ans = 9.0267
quadl(fun,kmin,kmax)
ans = 9.0268
quadgk(fun,kmin,kmax)
ans = 9.0268
Please note that a "." was missing in your equation (before the "/").
  1 件のコメント
Captain Singh
Captain Singh 2014 年 8 月 6 日
Thank you Michael.

サインインしてコメントする。

その他の回答 (1 件)

Christopher Berry
Christopher Berry 2014 年 8 月 5 日
The function name that you are looking for is integral not int. Changing this should get your code working. You can see the documentation for usage or examples here:
  1 件のコメント
Captain Singh
Captain Singh 2014 年 8 月 6 日
Firstly I had used "integral" but it didn't work. The error message was the same as above.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by