MATLAB: “Not enough input arguments” Help Don’t understand why

error function fzero

When I try and use the fzero function but keep getting this error:
Error using fzero (line 289) FZERO cannot continue because user supplied
function_handle ==> SCC failed with the error below.
Not enough input arguments.
Error in a6q7 (line 10)
q=fzero('SCC',1);
The script is as follows:
clear all
clc
z=sqrt(2)*sin(pi/4);
A =z*z;
B =z^0.5;
C =3+2*z;
x=0:10;
y=SCC(x,A,B,C);
plot(x,y)
q=fzero('SCC',1);
And the function SCC is:
function y = SCC(x,A,B,C)
y=A.*sin(x).*cos(x)+B.*cos(C.*x);
end
Thanks for any help!

Best Answer

Liam - according to the documentation for fzero, the input function handle is to a function that a accepts a scalar x and returns a scalar fun(x). Note that your function accepts four inputs, and so the error message, Not enough input arguments, makes sense since there fsolve will only try to provide one.
If x is your only variable into SCC, and the remaining three parameters, A, B, and C, are constant, then I would replace your line of code
q=fzero('SCC',1);
with an anonymous function that makes use of SCC as
q=fzero(@(x)SCC(x,A,B,C),1);
In the above, we are now supplying a function to fzero that will accept a single input argument only, and use the A, B, and C that have been defined previously. See anonymous functions for more details.
Try the above and see what happens!