Not enough input arguments. and too many input arguments. I'm confused about why this happened? thank you so much
1 view (last 30 days)
Show older comments
function y=CosxMinusx(x)
y=cos(x)-x;
end
function [ root ] = FindRoot ( a, b, N, tol, fcnHandle )
for n=1:N
root=a+(b-a)/2;
if fcnHandle(a)*fcnHandle(root)>0
a=root;
else
b=root;
end
[n a b root fcnHandle(root)]
if (b-a)/2<tol
break
end
end
>> CosxMinusx
Error using CosxMinusx (line 2)
Not enough input arguments.
>> FindRoot
Error using FindRoot (line 10)
Not enough input arguments.
>> FindRoot ( -10, 10, 100, 0.01, @CosxMinusx )
Error using FindRoot
Too many input arguments.
3 Comments
Image Analyst
on 2 Oct 2014
Hopefully those are in two different m-files because you are not allowed to mix the way you "finish" functions. You either have to omit "end"s for all functions or have "end"s for all functions but you can't mix them.
Answers (1)
Matt J
on 2 Oct 2014
Edited: Matt J
on 2 Oct 2014
Because you didn't pass any input arguments to CosxMinusx when you invoked it.
How is it supposed to evaluate
y=cos(x)-x;
when you didn't supply any input x value to the function?
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!