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 CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by