clc
clear
abar=input('Masukkan tebakan awal= ');
A=input('Amplitude= ');
dt=input('dt= ');
mu=input('mu = ');
ta=input('serta ta=');
t=0:dt:ta;
a(1)=abar;
n=length(t)
for i=1:(n-1)
   home
   k=i
   clc
	u(i)=A*sin(t(i));
	x(i)=-0.5*u(i)*abs(u(i));
	x1(i)=a(i)*u(i);
	e(i)=x(i)-x1(i);
	a(i+1)=a(i)+mu*u(i)*e(i);
end;
u(n)=A*sin(t(n));
x(n)=-0.5*u(n)*abs(u(n));
x1(n)=a(n)*u(n);
e(n)=x(n)-x1(n);
subplot(511),plot(t,u),xlabel('t'),ylabel('u(t)'),grid;
subplot(512),plot(t,x),xlabel('t'),ylabel('x(t)'),grid;
subplot(513),plot(t,x1),xlabel('t'),ylabel('x^(t)'),grid;
subplot(514),plot(t,e),xlabel('t'),ylabel('e(t)'),grid;
subplot(515),plot(t,a),xlabel('t'),ylabel('estimasi a'),grid;
pause
clf;
atot=0;
for k=(n-20):n
   atot=atot+a(k);
end
ar=atot/21
for j=1:100
   up(j)=A*sin(t(j));
	xp(j)=-0.5*up(j)*abs(up(j));
   x1p(j)=ar*up(j);
end
plot(up,xp,up,x1p,'*'),xlabel('isyarat masukan u(t)'),ylabel('isyarat keluaran x(t) dan x^(t)'),grid
