% energy.m % calculates the energy function for an input vector % % omega = inhibition constant % inVector = current state function Hb = energy (omega, inVector) u = inVector; W = iweight(omega); i = 1; n = 9; sumtotal = 0; while i <= n j = 1; while j <= n sumtotal = sumtotal + W(i,j)*u(i)*u(j); j = j+1; end i = i+1; end Hb = -0.5*sumtotal