www.pudn.com > AllNeuralNetworkCompute.rar > hopfield.m, change:2005-07-12,size:368b


close all; 
clear all; 
Q=[2 0;0 2]; 
P=[1 1]'; 
G=[1/2 1/4 1/8 1/16 1/32 0 0 0 0 0;0 0 0 0 0 1/2 1/4 1/8 1/16 1/32]; 
O_1=[1 -1 -1 -1 1 1 1 -1 -1 -1]'; 
W_value=-G'*Q*G; 
D=G'*P; 
W=W_value-diag(diag(W_value)); 
for k=1:100 
    O=sign(W'*O_1-D); 
    if O==O_1 
        k 
        break%如果达到稳态则停止 
    else 
    O_1=O 
    end 
end 
X=G*O 
F=0.5*X'*Q*X+P'*X