[Solved] matlab syntax errors in single layer neural network [closed]


Here’s a list of what I see wrong:

deep breath

  • The indexing syntax (:1) is incorrect. Perhaps you mean (:,1) as in “all rows of column 1”.
  • There is no such thing as a do…while loop in MATLAB. Only FOR and WHILE loops. Also, your for loop is defined wrong. MATLAB has a different syntax for that.
  • There are no ++ or += operators in MATLAB.
  • The “not equal” operator in MATLAB is ~=, not !=.
  • Indexing of vectors and matrices needs to be done with parentheses (), not square brackets [].
  • Is all of this inside a function or a script? You can not define functions, namely calculateOutput, in a script. You would have to put that in its own m-file calculateOutput.m. If all of the code is actually inside a larger function, then calculateOutput is a nested function and should work fine (assuming you have ended the larger enclosing function with an end).
  • You have a number of apparent typos for variable names:
    • weight vs. weights (as per phoffer’s answer)
    • Count vs. count (MATLAB is case-sensitive)
    • calculateOutput vs. calculateoutput (again, case-sensitivity)
    • learning rate vs. learningrate (variables can’t have spaces in them)

heavy exhale 😉

In short, it needs quite a bit of work.

2

solved matlab syntax errors in single layer neural network [closed]