MATLAB: I have aproblem in newelm

Deep Learning Toolboxelmannetnewelm

I used newelm to train the network and used the result of weight to make a pratic elman network but i had different result can i know where is thee wrong . when i used this code:
n=[0 1 0 1]
t=[1 0 1 0]
net=newelm(n,t,1,{'tansig','purelin'})
net=train(net,n,t)
wb=getwb(net)
o=sim(net,n)
n1=[-1 1 -1 1]
t1=[1 -1 1 -1]
h=0
for k=1:4
h=tansig(n1(k)*wb(2)+h*wb(3)+wb(1))
y(k)=purelin(h*wb(5)+wb(4))
end
thanks

Best Answer

Your values of wb(k) are in the wrong order. Try
IW = cell2mat(net.IW)
b = cell2mat(net.b)
LW = cell2mat(net.LW)
HTH
Greg