Not enough input arguments - Function

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

Answers (3)

Adam
Adam on 3 Mar 2016
Edited: Adam on 3 Mar 2016
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?
Yes, i'm trying tu run with the editor, how can i pass the arguments? do you have an example or something like that?

1 Comment

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.

Sign in to comment.

Sorry, this is so much for me xD, finally i understand how to run (:
Regards

Categories

Find more on Just for fun in Help Center and File Exchange

Asked:

on 3 Mar 2016

Answered:

on 3 Mar 2016

Community Treasure Hunt

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

Start Hunting!