Question: I run this code, but I have an error in "error function".
 The error message I get it:

Error using error

Too many output arguments. 

Does anyone know what is the problem?

```
w=2*rand(3,4)-1; % Randomly choosen between -1 and 1
x=[ 5 55 14 32; 4 4 84 5; 4 31 9 4; 4 45 99 2]; % Desired outputs
d=[ 1, 1, 0 ; 0, 1, 0 ; 0, 0, 1 ];

for j1=1:3,

 yi=w'*x(:,j1);                      % Network output
 y=sign(yi); 
 if sum(y-d(1,:)') > 0
  error = error+1
 end
end

```

Answer: 
The variable error is not defined and is used before defining it. As it is not defined.....it is taking the inbuilt matlab function error. **Don't use the variable names as MATLAB inbuilt funcitons**. You rename this variable as some other variable name, say myerror. Don't forget to initialize it. Check the below example code. 

```
for i = 1:10
    error = error+1 ;
end 

```

The above code shows error *Too many output arguments*. Because the code takes *error* is inbuilt function, as it is not initialized. 

```
error = 0 ;
for i = 1:10
    error = error+1 ;
end

```

The above works, as we have initialized *error*, code will not take the inbuilt function.
But the above is not suggested. Never overwrite the existing functions in matlab as variable names. The below is suggested.

```
myerror = 0 ;
for i = 1:10
    myerror = myerror+1 ;
end

```
I suspect that the source of your problem is because `error` is a MATLAB function and you try to use it as a variable, hence the error message "Error using error". Change your variable name to something like `my_error` or similar, and it should work.