Error: Not Enough Input Arguments
2 次查看(过去 30 天)
显示 更早的评论
"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
0 个评论
采纳的回答
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.
0 个评论
更多回答(1 个)
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".
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Quadratic Programming and Cone Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!