MATLAB: Not enough input arguments with fminunc

optimization econometrics

I wrote the followng code
global y t;
y = [1 2 4 6 4 12 11 13 11 14 16 17]';
T = length(y);
t = [1:T]';
x0 = [0, 0];
x = fminunc(@ssr, x0);
and function
function val = ssr(a, b)
global y t;
val = (y - a - b*t)'*(y - a - b*t);
end
when I run the code I get not enpugh input arguments error. I do not understand the reason. Could you help?

Best Answer

x = fminunc(@(x) ssr(x(1),x(2)), x0);