Integration over function between two limits

103 ビュー (過去 30 日間)
Sharath Kumar
Sharath Kumar 2019 年 12 月 3 日
コメント済み: Sharath Kumar 2020 年 1 月 16 日
format compact
syms x
f(x) = sin(x)
q = integral(f(x),0,pi)
when I run this I am facing the following error :
"Error using integral (line 82)
First input argument must be a function handle.
Error in integ (line 4)
q = integral(f(x),0,pi) "
Could you please explain why i am unable to put f(x) as a first input argument in the integral after defining the variable x.

回答 (2 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 12 月 3 日
syms x
f_x=@(x) sin(x)
q = integral(f_x,0,pi)
  1 件のコメント
Sharath Kumar
Sharath Kumar 2020 年 1 月 16 日
Thank You kalyan ! It worked.

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


Walter Roberson
Walter Roberson 2019 年 12 月 3 日
integral() is used only for numeric integration.
For symbolic integration, use int() if you want to see the closed form solution (if it exists), or use vpaintegral() for symbolic numeric solutions.
  1 件のコメント
Sharath Kumar
Sharath Kumar 2020 年 1 月 16 日
Thanks Walter !

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

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by