필터 지우기
필터 지우기

Plot shifting between two values in if statement

조회 수: 2 (최근 30일)
Rock Rocky
Rock Rocky 2017년 9월 6일
답변: dpb 2017년 9월 6일
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
-----------------------
  댓글 수: 2
Guillaume
Guillaume 2017년 9월 6일
편집: Guillaume 2017년 9월 6일
To provide a meaningful answer, we would have to retype the code you've provided in your screenshot, since it's not possible to copy text from a picture. That's a large burden you're putting onto us.
Instead of an image, copy/paste your code as text, using the {}Code button to format it as code.
As for the question, I'm not sure what you mean by plotting the shifting. What do you want to see in your plot? What's on the x axis, what's on the y axis?
Rock Rocky
Rock Rocky 2017년 9월 6일
I would like to plot c and d of the if statement with respect to the filter length. in order to prove that the algorithm is working and shifting between the two step size values c and d according to the if statement

댓글을 달려면 로그인하십시오.

채택된 답변

dpb
dpb 2017년 9월 6일
...
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
...

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D Function Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by