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-filecalculateOutput.m. If all of the code is actually inside a larger function, thencalculateOutputis a nested function and should work fine (assuming you have ended the larger enclosing function with anend). - You have a number of apparent typos for variable names:
weightvs.weights(as per phoffer’s answer)Countvs.count(MATLAB is case-sensitive)calculateOutputvs.calculateoutput(again, case-sensitivity)learning ratevs.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]