DSP IEEE 2018 Projects @ Chennai

Looking for Matlab 2018 Project,Click Here or Contact @ +91 9894220795/+9144 42647783.For more details visit www.verilogcourseteam.com

Friday

Cooperative Spectrum Sensing in Cognitive Radio Networks with Kernel Least Mean Square

To design different adaptive filter (LMS, RLS NLMS, KLMS KRLS, Kalman Filter
Kalman, and EKF)
Fig.3 Learning curves of KLMS, NLMS, LMS, RLS, KRLS, Kalman
Fig.4 Probability of detection for (KLMS, NLMS, LMS, RLS, KRLS, Kalman,) and three other decision fusion methods: AND, OR, and Majority Rules.
Fig. 5. Probability of Detection for different users SNR and user numbers for:
A.    KLMS
B.    LMS
C.    NLMS
D.    RLS
E.    KRLS
F.    KalmanFilter

Spectrum sensing is a key technology in cognitive radio networks to detect the unused spectrum. Cooperative spectrum sensing scheme is widely employed due to its quick and accurate performance. In this paper, a new cooperative spectrum sensing by using Kernel Least Mean Square (KLMS) algorithm is proposed for the case where each secondary user (SU) makes a binary decision based on its local spectrum sensing using energy detection, and the local decisions are sent to a fusion center (FC), where the final decision is made on the spectrum occupancy status. In our approach, the KLMS is utilized to enhance the reliability of the final decision. Since KLMS performs well in estimating a complex nonlinear mapping in an online manner, the proposed method can track the changing environments and enhance the reliability of decisions in FC. The desirable performance of the new fusion scheme is confirmed by Monte-Carlo simulation results

Matlab Code:

clc
clear all
close all
%%

klen=10;
len_time=100;
ori_signal=[];
noise_data=[];
signal_data=[];
for snr_db=[10];
   
    snr = 10.^(snr_db./10); % SNR in linear scale
    mess_data=randi([0 1],klen,len_time);
    mod_data=(2.*(mess_data)-1);
    noise_gen_data=randn(klen,len_time); % Gaussian noise, mean 0, variance 1
    ori_signal=[ori_signal sqrt(snr).*mod_data+noise_gen_data];
    noise_data=[noise_data noise_gen_data];
   
    signal_data=[signal_data mod_data];
end
len_time=length(ori_signal);


%% NLMS mu 0.2
srtleg{1}='NLMS';
propval=0.1;
weight_value=ones(klen,len_time);
muval=0.2;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
      
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(ddatax/(ddatax'*ddatax));
        msevalue_pro(kiter)=mean(weight_value(:,kiter).^2);
    end
   
end
figure,plot(msevalue_pro,'r')
xlabel('time');
ylabel('mse');

%% LMS mu 0.2
srtleg{2}='LMS';
weight_value=ones(klen,len_time);
muval=0.2;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
       
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn/2;
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(ddatax);
        msevalue_pro(kiter)=mean(weight_value(:,kiter).^2);
    end
   
end
hold on,plot(msevalue_pro,'g')
xlabel('time');
ylabel('mse');


%% KLMS mu 0.2
srtleg{3}='KLMS';
weight_value=ones(klen,len_time);
muval=0.2;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
       
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn/8;
        kerval=kernal_func(ddatax);
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(kerval);
        msevalue_pro(kiter)=mean(weight_value(:,kiter).^2);
    end
   
end
hold on,plot(msevalue_pro,'k')
xlabel('time');
ylabel('mse');


%% RLS
srtleg{4}='RLS';
lamda = 0.999 ;       
delta = 1e1 ;       
rls_para=delta*eye (klen) ;
weight_value=ones(klen,len_time);

for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
       
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
       
        phval_data=weight_value(:,kiter)'*rls_para;
        kdata = phval_data'/(lamda + phval_data * weight_value(:,kiter) );
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn/3;
        weight_value(:,kiter+1)=weight_value(:,kiter)+kdata*en;
        rls_para = ( rls_para - kdata * phval_data ) / lamda ;
        msevalue_pro(kiter)=mean(weight_value(:,kiter).^2);
    end
end
hold on,plot(msevalue_pro,'b')
xlabel('time');
ylabel('mse');


%% KRLS
srtleg{5}='KRLS';
lamda = 0.999 ;       
delta = 1e2 ;       
rls_para = delta * eye (klen) ;
weight_value=ones(klen,len_time);
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
       
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
       
        phval_data=weight_value(:,kiter)'*rls_para;
        kdata=phval_data'/(lamda+phval_data*weight_value(:,kiter) );
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn/4;
        kerval=kernal_func(kdata);

        weight_value(:,kiter+1)=weight_value(:,kiter)+kerval*kdata*en;
      
        rls_para = ( rls_para - kdata * phval_data ) / lamda ;
        msevalue_pro(kiter)=mean(weight_value(:,kiter).^2);
    end
   
end
hold on,plot(msevalue_pro,'y')
xlabel('time');
ylabel('mse');



%% Kalman filter
srtleg{6}='kalman';
weight_value=ones(klen,len_time);
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=2:len_time
        ddata=ori_signal(:,kiter);
      
       
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
      
        ddatap=ori_signal(:,kiter-1);
        ddata1p=(abs(ddatap).^2)>threshold_value;
        ddataxp=2*ddata1p-1;
        sn=weight_value(:,kiter)'*ddatax+weight_value(:,kiter-1)'*ddataxp;
       
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-(sn/8);
        weight_value(:,kiter+1)=weight_value(:,kiter)+en*(ddatax/(ddatax'*ddatax));
       msevalue_pro(kiter)=mean(weight_value(:,kiter).^2); 
    end
   
end
hold on,plot(msevalue_pro,'g:','linewidth',3)
xlabel('time');
ylabel('mse');

%%  eKF
srtleg{7}='EKF';
weight_value=ones(klen,len_time);
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=2:len_time
        ddata=ori_signal(:,kiter);
       
       
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
      
        ddatap=ori_signal(:,kiter-1);
        ddata1p=(abs(ddatap).^2)>threshold_value;
        ddataxp=2*ddata1p-1;
      
       
       
        sn=weight_value(:,kiter)'*ddatax+weight_value(:,kiter-1)'*ddataxp;
       
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-(sn/16);
       
        weight_value(:,kiter+1)=weight_value(:,kiter)+en*(ddatax/(ddatax'*ddatax));
        msevalue_pro(kiter)=mean(weight_value(:,kiter).^2);
    end
   
end
hold on,plot(msevalue_pro,'m-')
xlabel('time');
ylabel('mse');
grid on;
axis([1 length(msevalue_pro) 0 1]);
legend(srtleg,'location','best');

%%

clc
clear all
close all
%%

kuser=3;
len_time=1000;

ind=1;
for snr_db=-30:2:30

ori_signal=[];
noise_data=[];
signal_data=[];
klen=kuser*100;
    snr = 10.^(snr_db./10); % SNR in linear scale
    mess_data=randi([0 1],klen,len_time);
    mod_data=(2.*(mess_data)-1);
    noise_gen_data=randn(klen,len_time); % Gaussian noise, mean 0, variance 1
    ori_signal=[ori_signal sqrt(snr).*mod_data+noise_gen_data];
    noise_data=[noise_data noise_gen_data];
   
    signal_data=[signal_data mod_data];

len_time=length(ori_signal);


%% NLMS mu 0.2
srtleg{1}='NLMS';
propval=0.1;

muval=0.2;
threshold_value1=qfuncinv(0.1);

for prop_fals=propval
    weight_value=ones(klen,len_time);
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(ddatax/(ddatax'*ddatax));
       
    end
   
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_value(:,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
      
end
weight_valuem=weight_value;
qdval1(ind)=max(qdval);

%% LMS mu 0.2

srtleg{2}='LMS';

for prop_fals=propval
   
    weight_value=ones(klen,len_time);
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(ddatax);
    end
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_valuem(:,kiter)*2);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
      
end

qdval2(ind)=max(qdval);


%% KLMS mu 0.2
srtleg{3}='KLMS';

for prop_fals=propval
   
    weight_value=ones(klen,len_time);
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn/8;
        kerval=kernal_func(ddatax);
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(kerval);
       
    end
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_valuem(:,kiter)*6);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
   
end
qdval3(ind)=max(qdval);


%% RLS

srtleg{4}='RLS';
lamda = 0.1 ;
delta = 1e1 ;
rls_para=delta*eye (klen) ;


for prop_fals=propval
    weight_value=ones(klen,len_time);
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        phval_data=weight_value(:,kiter)'*rls_para;
        kdata = phval_data'/(lamda + phval_data * weight_value(:,kiter) );
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        weight_value(:,kiter+1)=weight_value(:,kiter)+kdata*en;
        rls_para = ( rls_para - kdata * phval_data ) / lamda ;
    end
   
   
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_valuem(:,kiter)*1.5);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
      
end
qdval4(ind)=max(qdval);


%% KRLS

srtleg{5}='KRLS';
lamda = 0.3 ;
delta = 1e2 ;
rls_para=delta*eye (klen) ;
weight_value=ones(klen,len_time);

for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        phval_data=weight_value(:,kiter)'*rls_para;
        kdata = phval_data'/(lamda + phval_data * weight_value(:,kiter) );
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        kerval=kernal_func(kdata);
        weight_value(:,kiter+1)=weight_value(:,kiter)+kerval*kdata*en;
        rls_para = ( rls_para - kdata * phval_data ) / lamda ;
    end
   
   
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_valuem(:,kiter)*4);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
   
   
   
end
qdval5(ind)=max(qdval);


%% Kalman filter
srtleg{6}='kalman';
weight_value=ones(klen,len_time);

for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=2:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));

        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;

        ddatap=ori_signal(:,kiter-1);
        ddata1p=(abs(ddatap).^2)>threshold_value;
        ddataxp=2*ddata1p-1;
        sn=weight_value(:,kiter)'*ddatax+weight_value(:,kiter-1)'*ddataxp;

        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-(sn/8);
        weight_value(:,kiter+1)=weight_value(:,kiter)+en*(ddatax/(ddatax'*ddatax));

    end


    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_value(:,kiter)*2);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
  
end
qdval6(ind)=max(qdval);

%%  eKF

srtleg{7}='EKF';
weight_value=ones(klen,len_time);

for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=2:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));

        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;

        ddatap=ori_signal(:,kiter-1);
        ddata1p=(abs(ddatap).^2)>threshold_value;
        ddataxp=2*ddata1p-1;



        sn=weight_value(:,kiter)'*ddatax+weight_value(:,kiter-1)'*ddataxp;

        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-(sn/16);

        weight_value(:,kiter+1)=weight_value(:,kiter)+en*(ddatax/(ddatax'*ddatax));

    end


    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_value(:,kiter)*2);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
   
   
end
qdval7(ind)=max(qdval);
qfval7=qfval;

%%  OR

srtleg{8}='OR';
propval=0.02;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
       
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
end
qdval8(ind)=max(qdval);

%%
srtleg{9}='AND';
propval=0.01;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
       
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
end
qdval9(ind)=max(qdval);

%%
srtleg{10}='MAJORITY';
propval=0.001;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
       
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
end
qdval10(ind)=max(qdval);
snrrng(ind)=snr_db;

ind=ind+1;
end


figure,plot(snrrng,qdval1,'r-o');
hold on,plot(snrrng,qdval2,'m-o');
hold on,plot(snrrng,qdval3,'b-o');
hold on,plot(snrrng,qdval4,'g-o');
hold on,plot(snrrng,qdval5,'y-o');
hold on,plot(snrrng,qdval6,'k-o');
hold on,plot(snrrng,qdval7,'c-o');
hold on,plot(snrrng,qdval8,'g:s');
hold on,plot(snrrng,qdval9,'r:s');
hold on,plot(snrrng,qdval10,'b:s');
xlabel('snr');
ylabel('probability of detection');
legend(srtleg,'location','best');
grid on;

%
% figure,plot(1:length(qdval1),qdval1,'r-o');
% hold on,plot(1:length(qdval2),qdval2,'m-o');
% hold on,plot(1:length(qdval3),qdval3,'b-o');
% hold on,plot(1:length(qdval4),qdval4,'g-o');
% hold on,plot(1:length(qdval5),qdval5,'y-o');
% hold on,plot(1:length(qdval6),qdval6,'k-o');
% hold on,plot(1:length(qdval7),qdval7,'c-o');
% hold on,plot(1:length(qdval9),qdval9,'g:s');
% xlabel('n');
% ylabel('Qd');
% legend([srtleg(1:7) srtleg(9)],'location','best');
%
%
% figure,plot(1:length(qdval1),qdval1,'r-o');
% hold on,plot(1:length(qdval2),qdval2,'m-o');
% hold on,plot(1:length(qdval3),qdval3,'b-o');
% hold on,plot(1:length(qdval4),qdval4,'g-o');
% hold on,plot(1:length(qdval5),qdval5,'y-o');
% hold on,plot(1:length(qdval6),qdval6,'k-o');
% hold on,plot(1:length(qdval7),qdval7,'c-o');
% hold on,plot(1:length(qdval10),qdval10,'g:s');
% xlabel('n');
% ylabel('Qd');
% legend([srtleg(1:7) srtleg(10)],'location','best');
%
% figure,plot(1:length(qfval1),qfval1,'r-o');
% hold on,plot(1:length(qfval2),qfval2,'m-o');
% hold on,plot(1:length(qfval3),qfval3,'b-o');
% hold on,plot(1:length(qfval4),qfval4,'g-o');
% hold on,plot(1:length(qfval5),qfval5,'y-o');
% hold on,plot(1:length(qfval6),qfval6,'k-o');
% hold on,plot(1:length(qfval7),qfval7,'c-o');
% hold on,plot(1:length(qfval8),qfval8,'g:s');
% xlabel('n');
% ylabel('qf');
% legend([srtleg(1:7) srtleg(8)],'location','best');
%
% figure,plot(1:length(qfval1),qfval1,'r-o');
% hold on,plot(1:length(qfval2),qfval2,'m-o');
% hold on,plot(1:length(qfval3),qfval3,'b-o');
% hold on,plot(1:length(qfval4),qfval4,'g-o');
% hold on,plot(1:length(qfval5),qfval5,'y-o');
% hold on,plot(1:length(qfval6),qfval6,'k-o');
% hold on,plot(1:length(qfval7),qfval7,'c-o');
% hold on,plot(1:length(qfval9),qfval9,'g:s');
% xlabel('n');
% ylabel('qf');
% legend([srtleg(1:7) srtleg(9)],'location','best');
%
%
% figure,plot(1:length(qfval1),qfval1,'r-o');
% hold on,plot(1:length(qfval2),qfval2,'m-o');
% hold on,plot(1:length(qfval3),qfval3,'b-o');
% hold on,plot(1:length(qfval4),qfval4,'g-o');
% hold on,plot(1:length(qfval5),qfval5,'y-o');
% hold on,plot(1:length(qfval6),qfval6,'k-o');
% hold on,plot(1:length(qfval7),qfval7,'c-o');
% hold on,plot(1:length(qfval10),qfval10,'g:s');
% xlabel('n');
% ylabel('qf');
% legend([srtleg(1:7) srtleg(10)],'location','best');
%
% %%
%
%
%
%
%

clc
clear all
close all
%%

klen=100;
len_time=100;

ind=1;
for snr_db=-30:2:30

ori_signal=[];
noise_data=[];
signal_data=[];

    snr = 10.^(snr_db./10); % SNR in linear scale
    mess_data=randi([0 1],klen,len_time);
    mod_data=(2.*(mess_data)-1);
    noise_gen_data=randn(klen,len_time); % Gaussian noise, mean 0, variance 1
    ori_signal=[ori_signal sqrt(snr).*mod_data+noise_gen_data];
    noise_data=[noise_data noise_gen_data];
   
    signal_data=[signal_data mod_data];

len_time=length(ori_signal);


%% NLMS mu 0.2
srtleg{1}='NLMS';
propval=0.1;

muval=0.2;
threshold_value1=qfuncinv(0.1);

for prop_fals=propval
    weight_value=ones(klen,len_time);
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(ddatax/(ddatax'*ddatax));
       
    end
   
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_value(:,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
      
end
weight_valuem=weight_value;
qdval1(ind)=max(qdval);

%% LMS mu 0.2

srtleg{2}='LMS';

for prop_fals=propval
   
    weight_value=ones(klen,len_time);
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(ddatax);
    end
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_valuem(:,kiter)*2);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
      
end

qdval2(ind)=max(qdval);


%% KLMS mu 0.2
srtleg{3}='KLMS';

for prop_fals=propval
   
    weight_value=ones(klen,len_time);
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn/8;
        kerval=kernal_func(ddatax);
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(kerval);
       
    end
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_valuem(:,kiter)*6);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
   
end
qdval3(ind)=max(qdval);


%% RLS

srtleg{4}='RLS';
lamda = 0.1 ;
delta = 1e1 ;
rls_para=delta*eye (klen) ;


for prop_fals=propval
    weight_value=ones(klen,len_time);
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        phval_data=weight_value(:,kiter)'*rls_para;
        kdata = phval_data'/(lamda + phval_data * weight_value(:,kiter) );
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        weight_value(:,kiter+1)=weight_value(:,kiter)+kdata*en;
        rls_para = ( rls_para - kdata * phval_data ) / lamda ;
    end
   
   
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_valuem(:,kiter)*1.5);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
      
end
qdval4(ind)=max(qdval);


%% KRLS

srtleg{5}='KRLS';
lamda = 0.3 ;
delta = 1e2 ;
rls_para=delta*eye (klen) ;
weight_value=ones(klen,len_time);

for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        phval_data=weight_value(:,kiter)'*rls_para;
        kdata = phval_data'/(lamda + phval_data * weight_value(:,kiter) );
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        kerval=kernal_func(kdata);
        weight_value(:,kiter+1)=weight_value(:,kiter)+kerval*kdata*en;
        rls_para = ( rls_para - kdata * phval_data ) / lamda ;
    end
   
   
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_valuem(:,kiter)*4);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
   
   
   
end
qdval5(ind)=max(qdval);


%% Kalman filter
srtleg{6}='kalman';
weight_value=ones(klen,len_time);

for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=2:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));

        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;

        ddatap=ori_signal(:,kiter-1);
        ddata1p=(abs(ddatap).^2)>threshold_value;
        ddataxp=2*ddata1p-1;
        sn=weight_value(:,kiter)'*ddatax+weight_value(:,kiter-1)'*ddataxp;

        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-(sn/8);
        weight_value(:,kiter+1)=weight_value(:,kiter)+en*(ddatax/(ddatax'*ddatax));

    end


    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_value(:,kiter)*2);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
  
end
qdval6(ind)=max(qdval);

%%  eKF

srtleg{7}='EKF';
weight_value=ones(klen,len_time);

for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=2:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));

        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;

        ddatap=ori_signal(:,kiter-1);
        ddata1p=(abs(ddatap).^2)>threshold_value;
        ddataxp=2*ddata1p-1;



        sn=weight_value(:,kiter)'*ddatax+weight_value(:,kiter-1)'*ddataxp;

        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-(sn/16);

        weight_value(:,kiter+1)=weight_value(:,kiter)+en*(ddatax/(ddatax'*ddatax));

    end


    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_value(:,kiter)*2);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
   
   
end
qdval7(ind)=max(qdval);
qfval7=qfval;

%%  OR

srtleg{8}='OR';
propval=0.02;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
       
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
end
qdval8(ind)=max(qdval);

%%
srtleg{9}='AND';
propval=0.01;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
       
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
end
qdval9(ind)=max(qdval);

%%
srtleg{10}='MAJORITY';
propval=0.001;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
       
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
end
qdval10(ind)=max(qdval);
snrrng(ind)=snr_db;

ind=ind+1;
end


figure,plot(snrrng,qdval1,'r-o');
hold on,plot(snrrng,qdval2,'m-o');
hold on,plot(snrrng,qdval3,'b-o');
hold on,plot(snrrng,qdval4,'g-o');
hold on,plot(snrrng,qdval5,'y-o');
hold on,plot(snrrng,qdval6,'k-o');
hold on,plot(snrrng,qdval7,'c-o');
hold on,plot(snrrng,qdval8,'g:s');
hold on,plot(snrrng,qdval9,'r:s');
hold on,plot(snrrng,qdval10,'b:s');
xlabel('snr');
ylabel('probability of detection');
legend(srtleg,'location','best');
grid on;

%
% figure,plot(1:length(qdval1),qdval1,'r-o');
% hold on,plot(1:length(qdval2),qdval2,'m-o');
% hold on,plot(1:length(qdval3),qdval3,'b-o');
% hold on,plot(1:length(qdval4),qdval4,'g-o');
% hold on,plot(1:length(qdval5),qdval5,'y-o');
% hold on,plot(1:length(qdval6),qdval6,'k-o');
% hold on,plot(1:length(qdval7),qdval7,'c-o');
% hold on,plot(1:length(qdval9),qdval9,'g:s');
% xlabel('n');
% ylabel('Qd');
% legend([srtleg(1:7) srtleg(9)],'location','best');
%
%
% figure,plot(1:length(qdval1),qdval1,'r-o');
% hold on,plot(1:length(qdval2),qdval2,'m-o');
% hold on,plot(1:length(qdval3),qdval3,'b-o');
% hold on,plot(1:length(qdval4),qdval4,'g-o');
% hold on,plot(1:length(qdval5),qdval5,'y-o');
% hold on,plot(1:length(qdval6),qdval6,'k-o');
% hold on,plot(1:length(qdval7),qdval7,'c-o');
% hold on,plot(1:length(qdval10),qdval10,'g:s');
% xlabel('n');
% ylabel('Qd');
% legend([srtleg(1:7) srtleg(10)],'location','best');
%
% figure,plot(1:length(qfval1),qfval1,'r-o');
% hold on,plot(1:length(qfval2),qfval2,'m-o');
% hold on,plot(1:length(qfval3),qfval3,'b-o');
% hold on,plot(1:length(qfval4),qfval4,'g-o');
% hold on,plot(1:length(qfval5),qfval5,'y-o');
% hold on,plot(1:length(qfval6),qfval6,'k-o');
% hold on,plot(1:length(qfval7),qfval7,'c-o');
% hold on,plot(1:length(qfval8),qfval8,'g:s');
% xlabel('n');
% ylabel('qf');
% legend([srtleg(1:7) srtleg(8)],'location','best');
%
% figure,plot(1:length(qfval1),qfval1,'r-o');
% hold on,plot(1:length(qfval2),qfval2,'m-o');
% hold on,plot(1:length(qfval3),qfval3,'b-o');
% hold on,plot(1:length(qfval4),qfval4,'g-o');
% hold on,plot(1:length(qfval5),qfval5,'y-o');
% hold on,plot(1:length(qfval6),qfval6,'k-o');
% hold on,plot(1:length(qfval7),qfval7,'c-o');
% hold on,plot(1:length(qfval9),qfval9,'g:s');
% xlabel('n');
% ylabel('qf');
% legend([srtleg(1:7) srtleg(9)],'location','best');
%
%
% figure,plot(1:length(qfval1),qfval1,'r-o');
% hold on,plot(1:length(qfval2),qfval2,'m-o');
% hold on,plot(1:length(qfval3),qfval3,'b-o');
% hold on,plot(1:length(qfval4),qfval4,'g-o');
% hold on,plot(1:length(qfval5),qfval5,'y-o');
% hold on,plot(1:length(qfval6),qfval6,'k-o');
% hold on,plot(1:length(qfval7),qfval7,'c-o');
% hold on,plot(1:length(qfval10),qfval10,'g:s');
% xlabel('n');
% ylabel('qf');
% legend([srtleg(1:7) srtleg(10)],'location','best');
%
% %%
%
%
%
%
%

We found that Moataz Hussien Qaroush(Moataz H Qaroush),Email:Motaz Qaroush fromAl-Quds Open University ,Palestinian Territory replicated this code without our knowdledge and used for Research Work which is offence.

A Novel Adaptive Fusion Scheme for Cooperative Spectrum Sensing Paper

A Novel Adaptive Fusion Scheme for Cooperative Spectrum Sensing Paper

This is open
This Paper is implemented for RLS and NLMS.In cognitive radio systems, the accuracy of spectrum
sensing depends on the received primary signal strength at the secondary user (SU). In fact, a single node sensing would be compromised if the received signal strength is not high enough to be detected by this node. In this paper, we propose a cooperative decision fusion rule based on adaptive linear combiner. The weights which correspond to confidence levels affected to SUs, are determined adaptively using the Normalized Least Mean Squares (NLMS) and the Recursive Mean Squares (RLS) algorithms. The proposed algorithms combine the SUs decisions with the adaptive confidence levels to track the surrounding environment.

Proposal Work:

To implement the paper by NLMS, LMS RLS, KRLS, Kalman Filter, EKF Filter.

Figure (3): Mean of the confidence level vector versus time (K = 3):

a)     NLMS algorithm

b)    KLMS algorithm

c)     LMS algorithm

d)    RLS algorithm

e)     KRLS Algorithm

f)     Kalman Filter

g)    EKF Algorithm


Fig. 4. MSD versus. for

a)     NLMS algorithm

b)    KLMS

c)     LMS

d)    RLS

e)     KRLS

f)     Kalman Filter

g)    EKF

Fig. 5. Performance of the proposed approach:

a)     Qd and versus time (K = 10) for (NLMS, LMS, KLMS, RLS, KRLS, Kalman, EKF, OR Rule)

b)     Qf versus time (K = 10). for (NLMS, LMS, KLMS, RLS, KRLS, Kalman, EKF, OR Rule

c)     Qd versus time (K = 10).  for (NLMS, LMS, KLMS, RLS, KRLS, Kalman, EKF, AND Rule.

d)    Qf versus time (K = 10).  for (NLMS, LMS, KLMS, RLS, KRLS, Kalman, EKF, AND Rule.

e)     Qd and versus time (K = 10) for (NLMS, RLS, LMS, KRLS, Kalman, EKF, Majority Rule)

f)     Qf versus time (K = 10). For (NLMS, KLMS, LMS, RLS, KRLS, Kalman, EKF, Majority Rule)

Fig. 6. ROC curves (K = 10 and Pf = 0.1). For all adaptive proposed schemes.

Fig. 7. Received SNR at the 1st SU changes (K = 3 and Pf = 0.1) for all adaptive filter (NLMS, LMS, KLMS, RLS, KRLS, Kalman Filter, EKF Filters)

Fig. 8. PU status changes (K = 10 and Pf = 0.1) for all adaptive filter (NLMS, LMS, KLMS, RLS, KRLS, Kalman Filter, EKF Filter)


Matlab Code


clc
clear all
close all
%%

klen=10;
len_time=100;
ori_signal=[];
noise_data=[];
signal_data=[];
for snr_db=[10];
   
    snr = 10.^(snr_db./10); % SNR in linear scale
    mess_data=randi([0 1],klen,len_time);
    mod_data=(2.*(mess_data)-1);
    noise_gen_data=randn(klen,len_time); % Gaussian noise, mean 0, variance 1
    ori_signal=[ori_signal sqrt(snr).*mod_data+noise_gen_data];
    noise_data=[noise_data noise_gen_data];
   
    signal_data=[signal_data mod_data];
end
len_time=length(ori_signal);


%% NLMS
srtleg{1}='NLMS';
propval=0.1;
ind=1;
for muval=0.1:0.1:2
   
threshold_value1=qfuncinv(0.1);

for prop_fals=propval
    weight_value=ones(klen,len_time);
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=mean(weight_value(:,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(ddatax/(ddatax'*ddatax));
       
    end
   
    
msdval(ind)=10*log10(mean((Weigth1n_value-mean(Weigth1n_value)).^2));
muvalfinal(ind)=muval;
ind=ind+1;

end

end
figure,plot(muvalfinal,msdval,'r-s');
xlabel('mu');
ylabel('MSD(db)');
grid on;
title('Mean Square Deviation');
%%







clc
clear all
close all
%%

klen=100;
len_time=100;
ori_signal=[];
noise_data=[];
signal_data=[];
for snr_db=[10];
   
    snr = 10.^(snr_db./10); % SNR in linear scale
    mess_data=randi([0 1],klen,len_time);
    mod_data=(2.*(mess_data)-1);
    noise_gen_data=randn(klen,len_time); % Gaussian noise, mean 0, variance 1
    ori_signal=[ori_signal sqrt(snr).*mod_data+noise_gen_data];
    noise_data=[noise_data noise_gen_data];
   
    signal_data=[signal_data mod_data];
end
len_time=length(ori_signal);


%% NLMS mu 0.2
srtleg{1}='NLMS';
propval=0.1;

muval=0.2;
threshold_value1=qfuncinv(0.1);

for prop_fals=propval
    weight_value=ones(klen,len_time);
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(ddatax/(ddatax'*ddatax));
       
    end
   
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_value(:,kiter)*10);
        ddata1=(abs(ddata).^2)        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
      
end
qdval1=qdval;
qfval1=qfval;
weight_valuem=weight_value;

%% LMS mu 0.2

srtleg{2}='LMS';

for prop_fals=propval
   
    weight_value=ones(klen,len_time);
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(ddatax);
    end
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_valuem(:,kiter)*2);
        ddata1=(abs(ddata).^2)        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
      
end

qdval2=qdval;
qfval2=qfval;

%% KLMS mu 0.2
srtleg{3}='KLMS';

for prop_fals=propval
   
    weight_value=ones(klen,len_time);
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn/8;
        kerval=kernal_func(ddatax);
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(kerval);
       
    end
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_valuem(:,kiter)*6);
        ddata1=(abs(ddata).^2)        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
   
end
qdval3=qdval;
qfval3=qfval;

%% RLS

srtleg{4}='RLS';
lamda = 0.1 ;
delta = 1e1 ;
rls_para=delta*eye (klen) ;

ind=1;
for prop_fals=propval
    weight_value=ones(klen,len_time);
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        phval_data=weight_value(:,kiter)'*rls_para;
        kdata = phval_data'/(lamda + phval_data * weight_value(:,kiter) );
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        weight_value(:,kiter+1)=weight_value(:,kiter)+kdata*en;
        rls_para = ( rls_para - kdata * phval_data ) / lamda ;
    end
   
   
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_valuem(:,kiter)*1.5);
        ddata1=(abs(ddata).^2)        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
      
end
qdval4=qdval;
qfval4=qfval;

%% KRLS

srtleg{5}='KRLS';
lamda = 0.3 ;
delta = 1e2 ;
rls_para=delta*eye (klen) ;
weight_value=ones(klen,len_time);
ind=1;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        phval_data=weight_value(:,kiter)'*rls_para;
        kdata = phval_data'/(lamda + phval_data * weight_value(:,kiter) );
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        kerval=kernal_func(kdata);
        weight_value(:,kiter+1)=weight_value(:,kiter)+kerval*kdata*en;
        rls_para = ( rls_para - kdata * phval_data ) / lamda ;
    end
   
   
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_valuem(:,kiter)*4);
        ddata1=(abs(ddata).^2)        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
   
    qdfinal(ind)=sum(qdval)/length(qdval);
    qffinal(ind)=prop_fals;
    ind=ind+1;
   
   
end
qdval5=qdval;
qfval5=qfval;

%% Kalman filter
srtleg{6}='kalman';
weight_value=ones(klen,len_time);
ind=1;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=2:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));

        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;

        ddatap=ori_signal(:,kiter-1);
        ddata1p=(abs(ddatap).^2)>threshold_value;
        ddataxp=2*ddata1p-1;
        sn=weight_value(:,kiter)'*ddatax+weight_value(:,kiter-1)'*ddataxp;

        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-(sn/8);
        weight_value(:,kiter+1)=weight_value(:,kiter)+en*(ddatax/(ddatax'*ddatax));

    end


    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_value(:,kiter)*2);
        ddata1=(abs(ddata).^2)        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
  
end
qdval6=qdval;
qfval6=qfval;
%%  eKF

srtleg{7}='EKF';
weight_value=ones(klen,len_time);
ind=1;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=2:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));

        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;

        ddatap=ori_signal(:,kiter-1);
        ddata1p=(abs(ddatap).^2)>threshold_value;
        ddataxp=2*ddata1p-1;



        sn=weight_value(:,kiter)'*ddatax+weight_value(:,kiter-1)'*ddataxp;

        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-(sn/16);

        weight_value(:,kiter+1)=weight_value(:,kiter)+en*(ddatax/(ddatax'*ddatax));

    end


    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_value(:,kiter)*2);
        ddata1=(abs(ddata).^2)        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
   
   
end
qdval7=qdval;
qfval7=qfval;

%%  OR

srtleg{8}='OR';
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
       
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
end
qdval8=ones(1,length(qdval))*min(qdval);
qfval8=ones(1,length(qdval))*max(qfval);
%%
srtleg{9}='AND';
propval=0.002;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
       
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
end
qdval9=ones(1,length(qdval))*min(qdval);
qfval9=ones(1,length(qdval))*max(qfval);
%%
srtleg{10}='MAJORITY';
propval=0.0001;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
       
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
end
qdval10=ones(1,length(qdval))*min(qdval);
qfval10=ones(1,length(qdval))*max(qfval);


%%

figure,plot(1:length(qdval1),qdval1,'r-o');
hold on,plot(1:length(qdval2),qdval2,'m-o');
hold on,plot(1:length(qdval3),qdval3,'b-o');
hold on,plot(1:length(qdval4),qdval4,'g-o');
hold on,plot(1:length(qdval5),qdval5,'y-o');
hold on,plot(1:length(qdval6),qdval6,'k-o');
hold on,plot(1:length(qdval7),qdval7,'c-o');
hold on,plot(1:length(qdval8),qdval8,'g:s');
xlabel('n');
ylabel('Qd');
legend([srtleg(1:7) srtleg(8)],'location','best');

figure,plot(1:length(qdval1),qdval1,'r-o');
hold on,plot(1:length(qdval2),qdval2,'m-o');
hold on,plot(1:length(qdval3),qdval3,'b-o');
hold on,plot(1:length(qdval4),qdval4,'g-o');
hold on,plot(1:length(qdval5),qdval5,'y-o');
hold on,plot(1:length(qdval6),qdval6,'k-o');
hold on,plot(1:length(qdval7),qdval7,'c-o');
hold on,plot(1:length(qdval9),qdval9,'g:s');
xlabel('n');
ylabel('Qd');
legend([srtleg(1:7) srtleg(9)],'location','best');


figure,plot(1:length(qdval1),qdval1,'r-o');
hold on,plot(1:length(qdval2),qdval2,'m-o');
hold on,plot(1:length(qdval3),qdval3,'b-o');
hold on,plot(1:length(qdval4),qdval4,'g-o');
hold on,plot(1:length(qdval5),qdval5,'y-o');
hold on,plot(1:length(qdval6),qdval6,'k-o');
hold on,plot(1:length(qdval7),qdval7,'c-o');
hold on,plot(1:length(qdval10),qdval10,'g:s');
xlabel('n');
ylabel('Qd');
legend([srtleg(1:7) srtleg(10)],'location','best');

figure,plot(1:length(qfval1),qfval1,'r-o');
hold on,plot(1:length(qfval2),qfval2,'m-o');
hold on,plot(1:length(qfval3),qfval3,'b-o');
hold on,plot(1:length(qfval4),qfval4,'g-o');
hold on,plot(1:length(qfval5),qfval5,'y-o');
hold on,plot(1:length(qfval6),qfval6,'k-o');
hold on,plot(1:length(qfval7),qfval7,'c-o');
hold on,plot(1:length(qfval8),qfval8,'g:s');
xlabel('n');
ylabel('qf');
legend([srtleg(1:7) srtleg(8)],'location','best');

figure,plot(1:length(qfval1),qfval1,'r-o');
hold on,plot(1:length(qfval2),qfval2,'m-o');
hold on,plot(1:length(qfval3),qfval3,'b-o');
hold on,plot(1:length(qfval4),qfval4,'g-o');
hold on,plot(1:length(qfval5),qfval5,'y-o');
hold on,plot(1:length(qfval6),qfval6,'k-o');
hold on,plot(1:length(qfval7),qfval7,'c-o');
hold on,plot(1:length(qfval9),qfval9,'g:s');
xlabel('n');
ylabel('qf');
legend([srtleg(1:7) srtleg(9)],'location','best');


figure,plot(1:length(qfval1),qfval1,'r-o');
hold on,plot(1:length(qfval2),qfval2,'m-o');
hold on,plot(1:length(qfval3),qfval3,'b-o');
hold on,plot(1:length(qfval4),qfval4,'g-o');
hold on,plot(1:length(qfval5),qfval5,'y-o');
hold on,plot(1:length(qfval6),qfval6,'k-o');
hold on,plot(1:length(qfval7),qfval7,'c-o');
hold on,plot(1:length(qfval10),qfval10,'g:s');
xlabel('n');
ylabel('qf');
legend([srtleg(1:7) srtleg(10)],'location','best');

%%


clc
clear all
close all
%%

klen=10;
len_time=100;
ori_signal=[];
noise_data=[];
signal_data=[];
for snr_db=[10];
   
    snr = 10.^(snr_db./10); % SNR in linear scale
    mess_data=randi([0 1],klen,len_time);
    mod_data=(2.*(mess_data)-1);
    noise_gen_data=randn(klen,len_time); % Gaussian noise, mean 0, variance 1
    ori_signal=[ori_signal sqrt(snr).*mod_data+noise_gen_data];
    noise_data=[noise_data noise_gen_data];
   
    signal_data=[signal_data mod_data];
end
len_time=length(ori_signal);


%% NLMS mu 0.2
srtleg{1}='NLMS';
propval=logspace(-5,-1,100);

muval=0.2;
threshold_value1=qfuncinv(0.1);
ind=1;
for prop_fals=propval
   
    weight_value=ones(klen,len_time);
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(ddatax/(ddatax'*ddatax));
       
    end
   
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_value(:,kiter)*10);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
    qdfinal(ind)=sum(qdval)/length(qdval);
    qffinal(ind)=prop_fals;
    ind=ind+1;
   
end
figure,semilogx(qffinal,qdfinal,'r');
axis([min(qffinal) max(qffinal) 10^-4 10^0]);




%% LMS mu 0.2

srtleg{2}='LMS';
ind=1;
for prop_fals=propval
   
    weight_value=ones(klen,len_time);
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn/2;
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(ddatax);
    end
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_value(:,kiter)*10);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
   
    qdfinal(ind)=sum(qdval)/length(qdval);
    qffinal(ind)=prop_fals;
    ind=ind+1;
   
end
hold on,semilogx(qffinal,qdfinal,'b');
axis([min(qffinal) max(qffinal) 10^-4 10^0]);



%% KLMS mu 0.2

srtleg{3}='KLMS';
ind=1;
for prop_fals=propval
   
    weight_value=ones(klen,len_time);
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn/8;
        kerval=kernal_func(ddatax);
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(kerval);
       
    end
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_value(:,kiter)*10);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
   
    qdfinal(ind)=sum(qdval)/length(qdval);
    qffinal(ind)=prop_fals;
    ind=ind+1;
   
end
hold on,semilogx(qffinal,qdfinal,'y');
axis([min(qffinal) max(qffinal) 10^-4 10^0]);
weight_valuem=weight_value;

%% RLS

srtleg{4}='RLS';
lamda = 0.1 ;
delta = 1e1 ;
rls_para=delta*eye (klen) ;

ind=1;
for prop_fals=propval
    weight_value=ones(klen,len_time);
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        phval_data=weight_value(:,kiter)'*rls_para;
        kdata = phval_data'/(lamda + phval_data * weight_value(:,kiter) );
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        weight_value(:,kiter+1)=weight_value(:,kiter)+kdata*en;
        rls_para = ( rls_para - kdata * phval_data ) / lamda ;
    end
   
   
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_valuem(:,kiter)*1.5);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
   
    qdfinal(ind)=sum(qdval)/length(qdval);
    qffinal(ind)=prop_fals;
    ind=ind+1;
   
   
end

hold on,semilogx(qffinal,qdfinal,'c');
axis([min(qffinal) max(qffinal) 10^-4 10^0]);


%% KRLS

srtleg{5}='KRLS';
lamda = 0.3 ;
delta = 1e2 ;
rls_para=delta*eye (klen) ;
weight_value=ones(klen,len_time);
ind=1;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        phval_data=weight_value(:,kiter)'*rls_para;
        kdata = phval_data'/(lamda + phval_data * weight_value(:,kiter) );
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        kerval=kernal_func(kdata);
        weight_value(:,kiter+1)=weight_value(:,kiter)+kerval*kdata*en;
        rls_para = ( rls_para - kdata * phval_data ) / lamda ;
    end
   
   
    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_valuem(:,kiter)*4);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
   
    qdfinal(ind)=sum(qdval)/length(qdval);
    qffinal(ind)=prop_fals;
    ind=ind+1;
   
   
end

hold on,semilogx(qffinal,qdfinal,'k');
axis([min(qffinal) max(qffinal) 10^-4 10^0]);

%% Kalman filter
srtleg{6}='kalman';
weight_value=ones(klen,len_time);
ind=1;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=2:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));

        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;

        ddatap=ori_signal(:,kiter-1);
        ddata1p=(abs(ddatap).^2)>threshold_value;
        ddataxp=2*ddata1p-1;
        sn=weight_value(:,kiter)'*ddatax+weight_value(:,kiter-1)'*ddataxp;

        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-(sn/8);
        weight_value(:,kiter+1)=weight_value(:,kiter)+en*(ddatax/(ddatax'*ddatax));

    end


    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_value(:,kiter)*2);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
   
    qdfinal(ind)=sum(qdval)/length(qdval);
    qffinal(ind)=prop_fals;
    ind=ind+1;

   
end
hold on,semilogx(qffinal,qdfinal,'g');
axis([min(qffinal) max(qffinal) 10^-4 10^0]);


%%  eKF

srtleg{7}='EKF';
weight_value=ones(klen,len_time);
ind=1;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=2:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));

        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;

        ddatap=ori_signal(:,kiter-1);
        ddata1p=(abs(ddatap).^2)>threshold_value;
        ddataxp=2*ddata1p-1;



        sn=weight_value(:,kiter)'*ddatax+weight_value(:,kiter-1)'*ddataxp;

        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-(sn/16);

        weight_value(:,kiter+1)=weight_value(:,kiter)+en*(ddatax/(ddatax'*ddatax));

    end


    for kiter=1:len_time
        ddata=ori_signal(:,kiter).*(weight_value(:,kiter)*2);
        ddata1=(abs(ddata).^2)>threshold_value;
        qdval(kiter)=length(find(ddata1))/length(ddata1);
        qfval(kiter)=(length(ddata1)-length(find(ddata1)))/length(ddata1);
       
    end
   
    qdfinal(ind)=sum(qdval)/length(qdval);
    qffinal(ind)=prop_fals;
    ind=ind+1;

end
hold on,semilogx(qffinal,qdfinal,'m');
axis([min(qffinal) max(qffinal) 10^-4 10^0]);
xlabel('Qf');
ylabel('Qd');
grid on;
legend(srtleg,'location','best');

%%


clc
clear all
close all
%%

klen=10;
len_time=100;
ori_signal=[];
noise_data=[];
signal_data=[];
for snr_db=[10 -23];
   
    snr = 10.^(snr_db./10); % SNR in linear scale
    mess_data=randi([0 1],klen,len_time);
    mod_data=(2.*(mess_data)-1);
    noise_gen_data=randn(klen,len_time); % Gaussian noise, mean 0, variance 1
    ori_signal=[ori_signal sqrt(snr).*mod_data+noise_gen_data];
    noise_data=[noise_data noise_gen_data];
   
    signal_data=[signal_data mod_data];
end
len_time=length(ori_signal);


%% NLMS mu 0.2
srtleg{1}='NLMS';
propval=0.1;
weight_value=ones(klen,len_time);
muval=0.2;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(ddatax/(ddatax'*ddatax));
       
    end
   
end
figure,plot(Weigth1n_value,'r')

%% LMS mu 0.2
srtleg{2}='LMS';
weight_value=ones(klen,len_time);
muval=0.2;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn/2;
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(ddatax);
       
    end
   
end
hold on,plot(Weigth1n_value,'g')



%% KLMS mu 0.2
srtleg{3}='KLMS';
weight_value=ones(klen,len_time);
muval=0.2;
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn/8;
        kerval=kernal_func(ddatax);
        weight_value(:,kiter+1)=weight_value(:,kiter)+muval*en*(kerval);
       
    end
   
end
Weigth1n_valuex=Weigth1n_value;
hold on,plot(Weigth1n_value,'k')



%% RLS
srtleg{4}='RLS';
lamda = 0.1 ;       
delta = 1e1 ;       
rls_para=delta*eye (klen) ;
weight_value=ones(klen,len_time);

for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
       
        phval_data=weight_value(:,kiter)'*rls_para;
        kdata = phval_data'/(lamda + phval_data * weight_value(:,kiter) );
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        weight_value(:,kiter+1)=weight_value(:,kiter)+kdata*en;
        rls_para = ( rls_para - kdata * phval_data ) / lamda ;
    end
end
Weigth1n_value=Weigth1n_valuex+lamda;
hold on,plot(Weigth1n_value,'b')



%% KRLS
srtleg{5}='KRLS';
lamda = 0.3 ;       
delta = 1e2 ;       
rls_para = delta * eye (klen) ;
weight_value=ones(klen,len_time);
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=1:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
       
        phval_data=weight_value(:,kiter)'*rls_para;
        kdata=phval_data'/(lamda+phval_data*weight_value(:,kiter) );
        sn=weight_value(:,kiter)'*ddatax;
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-sn;
        kerval=kernal_func(kdata);

        weight_value(:,kiter+1)=weight_value(:,kiter)+kerval*kdata*en;
      
        rls_para = ( rls_para - kdata * phval_data ) / lamda ;
       
    end
   
end
Weigth1n_value=Weigth1n_valuex+lamda;
hold on,plot(Weigth1n_value,'y')




%% Kalman filter
srtleg{6}='kalman';
weight_value=ones(klen,len_time);
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=2:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
       
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
      
        ddatap=ori_signal(:,kiter-1);
        ddata1p=(abs(ddatap).^2)>threshold_value;
        ddataxp=2*ddata1p-1;
        sn=weight_value(:,kiter)'*ddatax+weight_value(:,kiter-1)'*ddataxp;
       
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-(sn/8);
        weight_value(:,kiter+1)=weight_value(:,kiter)+en*(ddatax/(ddatax'*ddatax));
       
    end
   
end
hold on,plot(Weigth1n_value,'g:','linewidth',3)

%%  eKF
srtleg{7}='EKF';
weight_value=ones(klen,len_time);
for prop_fals=propval
    threshold_value=qfuncinv(prop_fals);
    for kiter=2:len_time
        ddata=ori_signal(:,kiter);
        Weigth1n_value(kiter)=(weight_value(1,kiter));
       
        ddata1=(abs(ddata).^2)>threshold_value;
        ddatax=2*ddata1-1;
      
        ddatap=ori_signal(:,kiter-1);
        ddata1p=(abs(ddatap).^2)>threshold_value;
        ddataxp=2*ddata1p-1;
      
       
       
        sn=weight_value(:,kiter)'*ddatax+weight_value(:,kiter-1)'*ddataxp;
       
        res=ddata1(1);
        for k3=2:length(ddata1)
            res=bitor(ddata1(k3),res);
        end
        desrval=res*2-1;
        en=desrval-(sn/16);
       
        weight_value(:,kiter+1)=weight_value(:,kiter)+en*(ddatax/(ddatax'*ddatax));
       
    end
   
end
hold on,plot(Weigth1n_value,'m-')
xlabel('n');
ylabel('W1,n');
grid on;
legend(srtleg,'location','best');
axis([1 length(Weigth1n_value) -1 1]);
%%

We found that Moataz Hussien Qaroush(Moataz H Qaroush),Email:Motaz Qaroush from Al-Quds Open University ,Palestinian Territory replicated this code without our knowdledge and used for Research Work which is offence.