clc
clear
abar=input('Masukkan tebakan awal= ');
tau=input('tau (time constant)= ');
mu=input('coba-coba mu kecil dan positif = ');
dt=input('dt= ');
T=dt;
ta=input('serta ta=');
a1(1)=abar;
a1(2)=abar;
a=1;
t=0:dt:ta;
n=length(t);
x(1)=sin(a*t(1));
x1(1)=sin(abar*t(1));
e(1)=x(1)*x1(1);
y(1)=0;
for i=2:(n-1)
   home
   k=i
   clc
   ab=a1(i);
   x(i)=sin(a*t(i));
   x1(i)=sin(ab*t(i));
   e(i)=x(i)*x1(i);
   y(i)=(1-exp(-T/tau))*e(i-1)+(exp(-T/tau))*y(i-1);
   a1(i+1)=a1(i)+mu*y(i);
end;
x(n)=sin(a*t(n));
ab=a1(n);
x1(n)=sin(ab*t(n));
e(n)=x(n)*x1(n);
y(n)=(1-exp(-T/tau))*e(n-1)+(exp(-T/tau))*y(n-1);
plot(t,x);
pause
clf
plot(t,x1);
pause
clf
plot(t,y);
pause
clf
plot(t,e);
pause
clf
plot(t,a1);
