Error:index must be a positive integer or logical.
Afficher commentaires plus anciens
Anybody can help me whats wrong with my code please. I am constantly getting this error Attempted to access f(1.99); index must be a positive integer or logical.
Error in extreme (line 22) y2=f(x2);
2 commentaires
Shehzad Ahmed
le 16 Avr 2017
navya sree
le 19 Jan 2019
Modifié(e) : navya sree
le 19 Jan 2019
%back propogation network Program
clear all;
clc;
disp('Back Propogation Network');
v=[0.7 -0.4;-0.2 0.3];
x=[0 1];
t=[1];
w=[0.5;0.1];
t1=0;
wb=-0.3;
vb=[0.4 0.6];
alpha=0.25
e=1;
temp1=0;
while (e<=3)
e
for i=1:2
for j=1:2
temp1=temp1+(v(j,i)*x(j));
end
zin(i)=temp1+vb(i);
temp1=e (-zin(i));
fz(i)=(1/(1+temp1));
z(i)=fz(i);
fdz(i)=fz(i)*(1-fz(i));
temp1=0;
end
for k=1
for j=1:2
temp1=temp1+z(j)*w(j,k);
end
yin(k)=temp1+wb(k);
fy(k)=(1/(1+(e -yin(k))));
y(k)=fy(k);
temp1=0;
end
for k=1
fdy(k)=fy(k)*(1-fy(k));
delk(k)=(t(k)-y(k))*fdy(k);
end
for k=1
for j=1:2
dw(j,k)=alpha*delk(k)*z(j);
end
dwb(k)=alpha*delk(k);
end
for j=1:2
for k=1
delin(j)=delk(k)*w(j,k);
end
delj(j)=delin(j)*fdz(j);
end
for i=1:2
for j=1:2
dv(i,j)=alpha*delj(j)*x(i);
end
dvb(i)=alpha*delj(i);
end
for k=1
for j=1:2
w(j,k)=w(j,k)+dw(j,k);
end
wb(k)=wb(k)+dwb(k);
end
w,wb
for i=1:2
for j=1:2
v(i,j)=v(i,j)+dv(i,j);
end
vb(i)=vb(i)+dvb(i);
end
v,vb
te(e)=e;
e=e+1;
end
i am getting this error please help me out in solving thank you in advance.
Attempted to access e(-0.2); index must be a positive integer or logical.
Error in backpropogation (line 22)
temp1=e (-zin(i));
%Kohonen Self organizing feature maps Program
clear all;
clc;
disp('Kohonen Self organizing feature maps');
disp('The input patterns are');
x=[1 1 0 0; 0 0 0 1; 1 0 0 0;0 0 1 1]
t=1;
alpha(t)=0.6;
e=1;
disp('Since we have 4 input pattern and cluster unit to be formed is 2, the weight matrix is');
w=[0.2 0.8; 0.6 0.4; 0.5 0.7; 0.9 0.3];
disp('the learning rate of this epoch is');
alpha
while(e<=3)
i=1;
j=1;
k=1;
m=1;
disp('Epoch =');
e
while(i<=4)
for j=1:2
temp=0;
for k=1:4
temp= temp + ((w(k,j)-x(i,k) 2);
end
D(j)=temp
end
if(D(1)<D(2))
J=1;
else
J=2;
end
disp('The winning unit is');
J
disp('Weight updation');
for m=1:4
w(m,J)=w(m,J) + (alpha(e) * (x(i,m)-w(m,J)));
end
w
i=i+1;
end
temp=alpha(e);
e=e+1;
alpha(e)=(0.5*temp);
disp('First Epoch completed');
disp('Learning rate updated for second epoch');
alpha(e)
end
i am getting below error
Error: File: kohonenself.m Line: 24 Column: 42
Unexpected MATLAB expression.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Numbers and Precision dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!