Check for missing argument or incorrect argument data type in call to function 'integral'.

94 ビュー (過去 30 日間)
I have an issue with my function has an integral. I wish to integrate a function with one of my input variables defined for my function, but Matlab wants me to use syms to define the variable. I already change interagal to 'int' but it still dosent work. Is there a way I can work around this issue? Any help is appreciated and thank you for your time.
f = sqrt(2)*x^3;
a = integral(f, 0, 9);
syms theta sin
g = 4+2*(sin^2*(theta));
b = integral(g, 0, pi/2);
ans = a*b

採用された回答

Voss
Voss 2021 年 12 月 27 日
syms x theta
f = sqrt(2)*x^3;
a = int(f, 0, 9)
a = 
g = 4+2*(sin(theta)^2);
b = int(g, 0, pi/2)
b = 
ans = a*b
ans = 

その他の回答 (1 件)

Meg Noah
Meg Noah 2021 年 12 月 28 日
One way is to use anonymous functions
f = @(x) sqrt(2)*x.^3;
g = @(theta) 4+2*(sin(theta).^2);
a = integral(f, 0, 9);
b = integral(g, 0, pi/2);
ans = a*b
  1 件のコメント
AIMAN FATINA MUHAMAD KAMAL
AIMAN FATINA MUHAMAD KAMAL 2022 年 1 月 4 日
thank you so much! both coding are same with my manual calculations.

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

Community Treasure Hunt

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

Start Hunting!

Translated by