First input argument must be a function handle

12 visualizaciones (últimos 30 días)
nesrine nesrine
nesrine nesrine el 13 de Sept. de 2014
Respondida: nesrine nesrine el 13 de Sept. de 2014
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?

Respuestas (2)

the cyclist
the cyclist el 13 de Sept. de 2014
Editada: the cyclist el 13 de Sept. de 2014
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 comentario
nesrine nesrine
nesrine nesrine el 13 de Sept. de 2014
Thank you but I have to integrate only the variable d

Iniciar sesión para comentar.


nesrine nesrine
nesrine nesrine el 13 de Sept. de 2014
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!!

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by