フィルターのクリア

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 Center および File Exchange2-D Function Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by