Effacer les filtres
Effacer les filtres

Error: Not Enough Input Arguments

2 vues (au cours des 30 derniers jours)
Zelda Luxenburry
Zelda Luxenburry le 6 Fév 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

Réponse acceptée

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

Plus de réponses (1)

Dr. Seis
Dr. Seis le 6 Fév 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".

Catégories

En savoir plus sur Quadratic Programming and Cone Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by