title: matlab syntax errors in single layer neural network
body: <p>I have to implement a single layer neural network or perceptron.For this,  I have 2 files data sets , one for the input and one for the output.I have to do this in matlab without using neural toolbox.The format of 2 files is given below.</p>
  
  <pre><code> In:
      0.832 64.643
      0.818 78.843
      1.776 45.049
      0.597 88.302
      1.412 63.458
  
  
  Out:
  0 0 1
  0 0 1
  0 1 0
  0 0 1
  0 0 1
  </code></pre>
  
  <p>The target output is "1 for a particular class that the corresponding input belongs to and "0 for the remaining 2 outputs.</p>
  
  <p>I tried to do this, But it is not working for me.</p>
  
  <pre><code>load in.data
  load out.data
  x = in(:1);
  y = in(:2);
  
  learning rate = 0.2;
  max_iteration = 50;
  
  function result = calculateOutput(weights,x, y)
  s = x*(weights(1) +weight(2) +weight(3));
  if s&gt;=0
   result = 1
  else:
   result = -1
  end
  end
  
  Count = length(x);
  weights[0] = rand();
  weights[1] = rand();
  weights[2] = rand();
  
  iter = 0;
  do {
    iter++;
    globalerror = 0;
    for(p=0; p&lt;count;p++){
      output = calculateoutput(weights,x[p],y[p]);
      localerror = output[p] - output
      weights[0]+= learningrate *localerror*x[p];
      weights[1]+= learningrate *localerror*y[p];
      weights[2]+= learningrate *localerror;
      globalerror +=(localerror*localerror);
     }
  }while(globalerror != 0 &amp;&amp; iter &lt;= max_iteration);
  </code></pre>
  
  <p>Where is the mistake in this algorithm??</p>
  
  <p>I am referring the example given in the link below:-</p>
  
  <p><a href="https://stackoverflow.com/questions/1697243/help-with-perceptron">Perceptron learning algorithm not converging to 0</a></p>