Clear Filters
Clear Filters

Error: Not Enough Input Arguments

2 views (last 30 days)
"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

Accepted Answer

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

More Answers (1)

Dr. Seis
Dr. Seis on 6 Feb 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".

Categories

Find more on Quadratic Programming and Cone Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!