MATLAB: Why i’m getting error Not enough input arguments.

MATLABsingle layer neural net

Error in sgd (line 12) t_x(k) = x(k, :)';
this is my code :
function weight = sgd(weight, x, a, b, correct_output)
alpha(1) = 0.7;
alpha(2) = 0.6;
alpha(3) = 0.4;
beta = 0.01;
gamma = 0.2;
N = 3;
for k = 1:N
t_x(k) = x(k, :)';
d = correct_output(k);
v(k) = a(k)*y(k-1) + (1-a(k))*v(k-1);
w_sum = weight*t_x + b(k)*v(k-1);
y = Sigmoid(w_sum);
error = d - y;
delta = y*(1-y)*error;
dweight = alpha*delta*t_x;
d_a = beta*delta*b(k)*(y(k-1) - v(k-1));
d_b = gamma*delta*v(k);
weight(1) = weight(1) - dweight(1);
weight(2) = weight(2) - dweight(2);
weight(3) = weight(3) - dweight(3);
a(k) = a(k) - d_a(k);
b(k) = b(k) - d_b(k);
end
end

Best Answer

You are trying to run the code by being in the editor and pressing the green Run button. When you do that, the function will be called without parameters, and the variables weight, x, a, b, correct_output will be undefined.
You need to either call the function from other code, or else go down to the command line and invoke it there, passing in appropriate values for weight, x, a, b, correct_output