how to fix Not enough input arguments in integral error ?

my function file is:
function func = myfun1(x,t,L)
func= (exp(-t.*cosh(x))).*cosh(L.*x);
end
and my script is:
xmin=0;
xmax=Inf;
L=[0;2];
T=1:1:10;
size=length(T);
mat=[size,2];
for i=1:2
for t=1:1:10
q=integral(@(x,t)myfun1(x,t,L(i)),xmin,xmax);
mat=[i;q];
end
end
i get the error Not enough input arguments.
i would like to know why and how to fix it thans :)

1 件のコメント

Torsten
Torsten 2019 年 8 月 2 日
"integral" only needs one input argument, not two.

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

回答 (1 件)

Srivardhan Gadila
Srivardhan Gadila 2019 年 8 月 5 日

0 投票

Change the function argument of integral to the following:
q=integral(@(x)myfun1(x,t,L(i)),xmin,xmax);
The integral function requires integrating w.r.t a single variable, which is ‘x’ in this case and since ‘t’ is constant w.r.t the integral, it should not be mentioned as variable in the integral function’s function argument.
You can refer to the documentation of integral

カテゴリ

ヘルプ センター および File ExchangeInteractive Control and Callbacks についてさらに検索

質問済み:

2019 年 8 月 2 日

回答済み:

2019 年 8 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by