Borrar filtros
Borrar filtros

Error: Not Enough Input Arguments

2 visualizaciones (últimos 30 días)
Zelda Luxenburry
Zelda Luxenburry el 6 de Feb. de 2012
"Error using quadroot (line 2). Not enough input arguments" why does it give me this error message? here is my code:
function [x] = quadroot(a,b,c)
if a==0
%special cases
if b ~= 0
%single root
x1 = -c/b;
else
%trivial solution
disp('Trivial solution.')
end
else
%quadratic equatioon
d = b^2 - 4*a*c;
if d>=0
x1 = (-b + sqrt(d))/(2*a);
x2 = (-b - sqrt(d))/(2*a);
else
x1 = -b/(2*a);
i1 = sqrt(abs(d))/(2*a);
x2 = x1;
end
end

Respuesta aceptada

Image Analyst
Image Analyst el 6 de Feb. de 2012
Because when you called it, or ran it if this is an m-file, you did not supply a, b, and c.

Más respuestas (1)

Dr. Seis
Dr. Seis el 6 de Feb. de 2012
A couple of questions:
1. How are you running this? If you are trying to run this from the Editor, then you will be running it without defining a, b or c.
2. Is this the actual code you are using? I ask because it the output argument "x" is never defined, though "x1" and "x2" are defined. Should replace x1 with x(1) and x2 with x(2).
3. What is "i1" used for? Your 4th to last line of code you define, but never use, "i1".

Categorías

Más información sobre Quadratic Programming and Cone Programming en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by