Code:
clc
clear all;
t=0:1/29:1;
f=1;
x=4*sin(2*pi*f*t);
x=[x ones(1,10) x];
y= zeros(1,length(X));
d= zeros(1,length(X));
e = zeros (1,length(x));
s=0.1;
for i=5: length(x)
if(x(i)-y(i-1))>=0
y(i)=x(i) +s;
d(i) = -1;
end
if(sum(d(i-4:i)))>3
s=s+0.01;
elseif(sum(d(i-4:i)))<-3
s=s+0.01;
else
s=s;
end
pause;
figure; plot(x);hold on;
stem(y,'m');e=x-y;plot(e,'r');
title('input,tracking and error graph');
subplot 212; stem (d,'k');title('output data signal')
end
Output:
0 comments:
Post a Comment