Not enough input arguments - Function
Mostrar comentarios más antiguos
Hello, this is my first post here, i'm trying to run a code for Müller Algorithm but, i was searching another noted about the issue but i don't found anything:
"Not enough input arguments.
Error in Muller (line 4) fx = inline(f);"
if true
%Metodo Muller
function [xr , T] = muller(f , xr , h , c , e)
%crear funcion a partir del parametro texto
fx = inline(f);
%Crear los 3 puntos a partir del parametro I
x2=xr;
x1=xr+h;
x0=xr-h;
%inicializar varias auxiliares
k=0;
sigue=1;
T=[0 0 0 0];
while(sigue)
k=k+1;
%calculo de A, B y C
h0=x1-x0;
h1=x2-x1;
d0=(fx(x1)-fx(x0))/h0;
d1=(fx(x2)-fx(x1))/h1;
a=(d1-d0)/(h1+h0);
b=a*h1+d1;
c=fx(x2);
%obtener la raiz
raizd=sqrt(b*b-4*a*c);
%determina que valor es mas grande
if abs(b+raizd)>abs(b-raizd)
den=b+raizd;
else
den=b-raizd;
end
%calcular siguiente valor
dxr=-2*c/den;
xr=x2+dxr;
sigue=abs(dxr)/xr>e||k<c||abs(fx(xr))>e;
x0=x1;
x1=x2;
x2=xr;
T(k,:)=[x0 x1 x2 fx(xr)];
end
Respuestas (3)
I am guessing you are just running your function using the 'Run' or 'Play' button in the editor.
A function is not like a script. It takes input arguments (often) and these need to be passed in. To do this you have to call the function either from the command line, from a script or from another function where you can pass in your arguments. e.g.
[xr , T] = muller(f , xr , h , c , e);
where f, xr, h, c and e are defined in whatever workspace you call the function from.
Surely you should have been asking yourself "How do I pass the arguments in?" when you were trying to run this function?
Luis Menendez
el 3 de Mzo. de 2016
0 votos
1 comentario
Adam
el 3 de Mzo. de 2016
I gave an example in my answer above. I don't know where you are getting your arguments from, but just put a script together that defines all your arguments then call your function as I showed.
Luis Menendez
el 3 de Mzo. de 2016
0 votos
Categorías
Más información sobre Just for fun en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!