Professional Documents
Culture Documents
Koding: Function If Elseif Else End End
Koding: Function If Elseif Else End End
%name :bipolar.m
function y=bipolar(x,th)
if x> th
y=1;
elseif x < (-1*th)
y = -1;
else
y = 0;
end
end
%name :satlin.m
clc
bipolar(0.2,1)
bipolar(3.5,1)
bipolar(-0.3,1)
bipolar(-5.5,1)
%name :sigmoid.m
function y=sigmoid(x)
a=0.5;
y=1./(1+exp(-1*a.*x));
end
%name :sigbib.m
clc
sigmoid(0.2)
sigmoid(3.5)
sigmoid(-0.3)
sigmoid(-5.5)
%name :lhebb.m
for k=1:length(pm(1,:))
disp('data ke'),k
s = pm(k,:);
x=s;
t=pt(k,:);
y=t';
end
end
%prakt 7
clc
clear
pm = [-1 -1; -1 1; 1 -1; 1 1];
pt = [-1 ; 1 ; 1 ; 1 ];
w = lhebb(pm,pt)
%simhebb.m
function y=simhebb(px,w)
yin = px*w';
if yin>0
y=1;
else
y=-1;
end
end
clc
clear
Px=input('masukan pola data yang diujikan');
load('bobot.mat')
bobot=w
y=simhebb(Px,w)