You are on page 1of 7

PH LC

Ph Lc
%% %%%CHUONG TRINH DIEU KHIEN CONG SUAT BUOC CO DINH%%%%%
%%%%%%%%%%%%% NUT BUOC CO DINH%%%%%%%%%%%%%%%%%
function pushbutton1_Callback(hObject, eventdata, handles)
congsuatphat=str2double(get(handles.edit2,'string'));
user=str2double(get(handles.edit1,'string'));
In=14.200;
% cong suat nhieu ,In = No*B/nc,No laf mat do cong suat nhieu,B bang tan
moi song mang
nc=8.000;
%congsuatcuatungsongmang;
deltaP=0.500;
%buoc dieu khien cong suat
NumAngles=2^4; Length=2^8; symbolRate=9.6; NumWaveforms=2; carrierFreq=1.2286;
Velocity=36;
C=3e8;
alpha=RayCh1(NumAngles, Length, symbolRate, NumWaveforms,carrierFreq, Velocity);
sipow = tinhieu(user);
sigpower1=congsuatphat;
%sigpower=abs((20*log(out))/4 phuong phap fixed-step
sigpower2=congsuatphat;
%phuong phap multi-level
G=8.000;
snrchuan=abs(G/user);
% gia tri snr chuan
Y1=[];
Y2=[];
e=0.025*deltaP;
deltaP1=0.250;
for i=1:80
alpha1=randint(1,1,[975 980])*1e-03;
snr1=(sigpower1*alpha1^2*G)/((user-1)*sigpower1+In);
Y1(i)=sigpower1;
if snr1 >= snrchuan
sigpower1= sigpower1-deltaP;
else
sigpower1=sigpower1+deltaP;
end
end
Y=Y1;
bar([Y]','group');
xlabel('time(x1.25msec)');
ylabel('cong suat phat(dB)');
title('fixstep');
grid on
%%%%%%%%%CHUONG TRINH DIUE KHIEN CONG SUAT DA MUC%%%%%%%%
%%%%%%%%%%%%%%%%% NUT AN DA MUC%%%%%%%%%%%%%%%%%%
function pushbutton2_Callback(hObject, eventdata, handles)
congsuatphat=str2double(get(handles.edit2,'string'));
user=str2double(get(handles.edit1,'string'));

PH LC
In=14.200;
% cong suat nhieu ,In = No*B/nc,No laf mat do cong suat nhieu,B bang tan
moi song mang
nc=8.000;
deltaP=0.500;
%buoc dieu khien cong suat
alpha=0.94;
sipow = tinhieu(user);
sigpower1=congsuatphat;
%sigpower=abs((20*log(out))/4 phuong phap fixed-step
sigpower2=congsuatphat;
%phuong phap multi-level
G=8.000;
snrchuan=abs(G/user);
% gia tri snr chuan
Y1=[];
Y2=[];
e=0.025*deltaP;
deltaP1=0.250;
for i=1:80
alpha2=randint(1,1,[975 960])*1e-03;
snr2=(sigpower2*alpha2^2*G)/((user-1)*sigpower2+In);
Y2(i)=sigpower2;
if snr2-snrchuan < -5*e
sigpower2=sigpower2+3*deltaP1;
elseif snr2-snrchuan <-3*e
sigpower2=sigpower2+2*deltaP1;
elseif -3*e <= snr2-snrchuan < -e
sigpower2=sigpower2+deltaP1;
elseif -e <=snr2-snrchuan < e
sigpower2=sigpower2;
elseif e <= snr2-snrchuan < 3*e
sigpower2=sigpower2 -deltaP1;
else
sigpower2=sigpower2-2*deltaP1;
end
end
y2=Y2;
bar([y2]','group');
xlabel('time(x1.25msec)');
ylabel('cong suat phat(dB)');
title('multilevel');
grid on;
%%%%%%%%%%CHUONG TRINH DIEU KHIEN CONG SUAT DA MUC%%%%%%%
%%%%%%%%%%%%%%%%%NUT AN DA MUC%%%%%%%%%%%%%%%%%%%
function pushbutton3_Callback(hObject, eventdata, handles)
congsuatphat=str2double(get(handles.edit2,'string'));
user=str2double(get(handles.edit1,'string'));
In=14.200;
% mat do cong suat nhieu
nc=8.000;
%so song mang ,bang he so do loi
deltaP=0.0250;
%buoc dieu khien cong suat
%alpha=0.95 ;

PH LC
cuongdo=tinhieu(user)
sigpower2=congsuatphat-1;
%phuong phap multi-level
G=32.000;
snrchuan=abs(G/user);
% gia tri snr chuan
Y1=[];
Y3=[];
e=0.5*deltaP;
Pbit=1;
sigpowerI=In*(snrchuan)/(G-(snrchuan)*(user-1));
[tetra,r]=gtdelta(Pbit);
gama=1.3;
for i=1:80
%snr2=(sigpower2*alpha^2*G)/(3*sigpower2+In);
Y3(i)=sigpower2;
alpha=randint(1,1,[981 965]);
alpha1=alpha*1e-03;
if (tetra <=0) & (r<=0)
% dieu khien de du doan
rama(i)=Pbit-tetra;
else
rama(i) =Y3(i)*alpha1^2-sigpowerI;
end
if (rama(i) < -5*e)
%phuong phap tinh C
sigpower2=sigpower2+3*deltaP;
elseif (rama(i) < -3*e)
sigpower2=sigpower2+2*deltaP;
elseif (-3*e <= rama(i) < -e)
sigpower2=sigpower2 + deltaP;
elseif (-e<=rama(i)< e)
sigpower2=sigpower2;
elseif ( e <= rama(i) < 3*e)
sigpower2=sigpower2-deltaP;
else
sigpower2=sigpower2-2*deltaP;
end
end
y=Y3*gama;
bar([y]','group');
xlabel('time(x1.25msec)');
ylabel('cong suat phat(dB)');
title('predictive');
grid on;
%%%%%%%%%% CHUONG TRINH SO SANH DIEU KHIEN CONG SUAT%%%%%
%%%%%%%%% %% CHUONG TRINH CONG SUAT PHAT%%%%%%%%%%%%%
function pushbutton1_Callback(hObject, eventdata, handles)
cla(handles.axes1)
user=str2double(get(handles.edit1,'string'));
congsuatphat=str2double(get(handles.edit2,'string'));

PH LC
[Y1,Y2]=dkcs1(user,congsuatphat);
Y3=csdudoan(user,congsuatphat);
i=1:1:80;
%bar([Y1]','grouped')
hold on
plot(i,Y1,'r-');
plot(i,Y2,'k-');
plot(i,Y3,'b*-');
%axis([0, 80,13, 20]);
xlabel('time(x1.25msec)');
ylabel('cong suat phat(dB)');
legend('buoc co dinh','da muc','du doan');
grid on
hold off
%%%%%%%%%%%%%%%% CHUONG TRINH SO SANH SRN%%%%%%%%%%%
%% %%%%%%%%%%%%%%%%NUT AN SO SANH SRN%%%%%%%%%%%%%
function pushbutton2_Callback(hObject, eventdata, handles)
cla(handles.axes1)
user=str2double(get(handles.edit1,'string'));
congsuatphat=str2double(get(handles.edit2,'string'));
[Y1,Y2]=dkcssnr(user,congsuatphat);
Y4=dkdudoansnr(user,congsuatphat);
i=1:1:80
hold on
plot(i,Y1,'r-');
plot(i,Y2,'k-');
plot(i,Y4,'b-');
%axis([0, 80,3,4]);
xlabel('time(x1.25msec)');
ylabel('SNR(dB)');
legend('buoc co dinh','da muc','du doan');
grid on
hold off
% %%%%%%%%%%CHUONG TRINH SO SANH BER%%%%%%%%%%%%%%%%
function pushbutton3_Callback(hObject, eventdata, handles)
cla(handles.axes1)
user=str2double(get(handles.edit1,'string'));
congsuatphat=str2double(get(handles.edit2,'string'));
y1=nhapthu(user,congsuatphat);
y2=nhapthu2(user,congsuatphat);
y3=nhapthu3(user,congsuatphat);
hold on
axis([5,user,1e-05,1e-01]);
semilogy(y1,'r-');
semilogy(y2,'k-');
semilogy(y3,'b-');
%axis([5,user,1e-05,1e-01]);

PH LC
%axis([4,50,1e-05,1e-01]);
%axis([5,user,1e-05,1e-01]);
grid on
hold off
xlabel('number of Users');ylabel('BER');
legend('du doan','buoc co dinh','da muc');
grid on
hold off
%%%%%%%%%% %CHUONG TRINH BASED BANH%%%%%%%%%%%%%%%%
%%%%%%%%%%%NUT AN SNR BASED BAND SELECTION%%%%%%%%%%%
%%%%%%%%%%%CHUONG TRINH BASE BAND SELECTION%%%%%%%%%%
function pushbutton1_Callback(hObject, eventdata, handles)
user=str2double(get(handles.edit1,'string'));
congsuat=str2double(get(handles.edit2,'string'));
Y=thu(user,congsuat);
H=3000000;
for i=1 : user
for j=1:8
Y1(i,j)=Y(i,j)/(sum(Y(:,j))-Y(i,j));
end
y2(i)=max(Y1(i,:)) ;
end
b=y2;
for i=1:user
%syms y1(i) positive;
S(i)=qfunc(b(i));
end
f=S;
syms y real
for i=1:user
%P2(i)=int(S,y,0,inf)
F= mvnpdf(y);
P1=int(F,y,0,inf);
P(i)=P1*f(i);
k(i)=i^3*(double(P(i)))/H;
%P(i)=single(P1(i))
end
v2=k;
semilogy(v2,'k*-.')
xlabel('Number of User');
ylabel('BER');
title('BER cho he thong 1/16');
axis([5,15,1e-06,1e-01]);
grid on
% --- Executes on button press in pushbutton2.
%%%%%%%%%%%CHUONG TRINH POWER BASED BAND SELECTION%%%%%%
function pushbutton2_Callback(hObject, eventdata, handles)

PH LC
user=str2double(get(handles.edit1,'string'));
congsuat=str2double(get(handles.edit2,'string'));
Y=thu(user,congsuat);
H=1000000;
for i=1:user
y1(i)=max(Y(i,:));
end
for i=1:user
%syms y1(i) positive;
b(i)=y1(i)/(sum(y1)-y1(i))
S(i)=qfunc(b(i));
end
f=S;
syms y real
for i=1:user
%P2(i)=int(S,y,0,inf)
F= mvnpdf(y);
P1=int(F,y,0,inf);
P(i)=P1*f(i);
k(i)=i^2*(double(P(i)))/H;
%P(i)=single(P1(i))
end
v1=k;
semilogy(v1,'m+-')
xlabel('Number of User');
ylabel('BER');
title('BER cho he thong 1/16');
axis([5,15,1e-06,1e-01]);
grid on
%%%%%%%%%%%%%%%%%%CHUONG TRINH SO SANH%%%%%%%%%%%
function pushbutton3_Callback(hObject, eventdata, handles)
user=str2double(get(handles.edit1,'string'));
congsuat=str2double(get(handles.edit2,'string'));
v1=thu2(user,congsuat);
v2=thu3(user,congsuat);
hold on
i=1:1:user
title('BER cho he thong 1/16');
semilogy(i,v1,'b*-.');
semilogy(i,v2,'r+-.');
axis([5,15,1e-6,1e-1]);
xlabel('Number of User');
ylabel('BER');
axis([5,user,1e-06,1e-01]);
legend('SNR-Based Band Selection','Power-Based Band Selection');
grid on
hold off

PH LC

You might also like