MATLAB: Plot shifting between two values in if statement

plot if statement

Hello there I have if statement contain two equations as shown in the attached picture. This algorithm have two step size values represented by c and d respectively. The algorithm will shift between these two values according to the if statement. how can I plot the shifting between c and d. Thanks in advance.
if true
echo on
r=0;
N=500;
K=5;
num=0;
sum=0;
actual_isi=[0.05 -0.063 0.088 -0.126 -0.25 0.9047 0.25 0.126 0.038 0.088];
sigma=0.01;
delta=0.09;
deviation=0.004;
Num_of_Realizations = 1000;
mse_av=zeros(1,N-2*K);
c=delta+deviation;
d=delta-deviation
for j=1:Num_of_Realizations,
%information sequence
for i=1:N,
if (rand<0.5),
info(i)=-1;
else
info(i)=1;
end;
echo off;
end;
if (j==1);echo on ; end
%The Channel Output
y=filter(actual_isi,1,info);
for i=1:2:N, [noise(i) noise(i+1)]=gngauss(sigma); end;
y=y+noise;
%Now the Equalization part follows
estimated_c=[0 0 0 0 0 1 0 0 0 0 0]; %Initial Estimate of ISI
e_k1=0;
cnt = 1; % Loop counter.
for k=1:N-2*K,
y_k=y(k:k+2*K);
z_k=estimated_c*y_k.';
e_k=info(k)-z_k;
n=norm(y_k);
if(e_k>e_k1)
estimated_c=estimated_c+(c)*e_k*y_k/n;
elseif(e_k<=e_k1)
estimated_c=estimated_c+(d)*e_k*y_k/n;
end
e_k1=e_k;
% estimated_c=estimated_c+delta*e_k*y_k;
mse(k)=e_k^2;
echo off;
end;
if (j==1); echo on; end
mse_av = mse_av + mse;
echo off;
end;
end
-----------------------

Best Answer

...
for k=1:N-2*K,
...
if(e_k>e_k1)
estimated_c=estimated_c+(c)*e_k*y_k/n;
plot(k,estimated_c,'rx')
elseif(e_k<=e_k1)
estimated_c=estimated_c+(d)*e_k*y_k/n;
plot(k,estimated_c,'go')
end
if k==1,hold on,end
...
Related Question