フィルターのクリア

Error: Not Enough Input Arguments

2 ビュー (過去 30 日間)
Zelda Luxenburry
Zelda Luxenburry 2012 年 2 月 6 日
"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

採用された回答

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

その他の回答 (1 件)

Dr. Seis
Dr. Seis 2012 年 2 月 6 日
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".

カテゴリ

Help Center および File ExchangeQuadratic Programming and Cone Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by