First input argument must be a function handle

12 ビュー (過去 30 日間)
nesrine nesrine
nesrine nesrine 2014 年 9 月 13 日
回答済み: nesrine nesrine 2014 年 9 月 13 日
Hello, Please!!!!! i need help. I'm trying to solve an integral function :
r=0:0.02:0.2;
d=[0.0005;0.001;0.0015;0.002;0.0025;0.003;0.0035;0.004;0.0045;0.005;0.0055];
fun={@(d,r) d.^3*exp(-4.1*(r.^(-0.21)*d))};
F=integral(fun,0.0005,0.0055);
But it returns : "First input argument must be a function handle"
Please how can i solve this problem?

回答 (2 件)

the cyclist
the cyclist 2014 年 9 月 13 日
編集済み: the cyclist 2014 年 9 月 13 日
There were a couple problems here.
First, you put your function in side a cell array (with the curly brackets), which is unnecessary, and is why MATLAB did not recognize fun as a function handle.
Second, you seem to want to do a double integral, but you used integral() rather than integral2().
Third, your function definition used matrix multiplication rather than element-wise multiplication in a couple places.
The following code fixes all of these problems, but I can't say for sure is what you intended to do:
fun=@(d,r) d.^3.*exp(-4.1.*(r.^(-0.21).*d));
F=integral2(fun,0.0005,0.0055,0,0.2);
Note that your pre-definition of r and d vectors is going to be ignored by integral2(). These two lines will execute on their own.
  1 件のコメント
nesrine nesrine
nesrine nesrine 2014 年 9 月 13 日
Thank you but I have to integrate only the variable d

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


nesrine nesrine
nesrine nesrine 2014 年 9 月 13 日
Thanks i solved this problem
But i faced an other error in function plot :
fun=@(d,r) d.^3.*exp(-4.1.*(r.^(-0.21).*d));
F=integral2(fun,0.0005,0.0055,0,0.2);
L=((0.434*10^4*8*2100)/3)*F;
L1=distance*L;
ezplot(r,d,L); it seems that it's not the suitable function plot that i have to integrate. please helppp!!

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by