基于博弈论的频谱分配(MATLAB实现)

代码:

Matlab 复制代码
clc
clear all

B=15;
BER=10^(-4);
K=1.5/(logm(0.2/BER)); SNR=[8,10]; k=log2(1+K.*SNR); r1=10;
r2=12; x=0; y=1; z=1;
% b=[0,0];
% c=x+y*(sum(b));
% p=r.*k.*b-b.*c;


a(1)=0.001;
for i=1:300 a(2)=0.001;
for j=1:300
eigenvalue(1)=1-10/3*(2*a(1)*k(1)-a(1)*k(2)+2*a(2)*k(2)- a(2)*k(1))+10/3*((a(1)*(k(2)-2*k(1))*a(2)*(k(1)-2*k(2))+(2*a(2)*k(2)- a(2)*k(1)-2*a(1)*k(1)+a(1)*k(2))^2)^(0.5));
eigenvalue(2)=1-10/3*(2*a(1)*k(1)-a(1)*k(2)+2*a(2)*k(2)-a(2)*k(1))-10/3*((a(1)*(k(2)-2*k(1))*a(2)*(k(1)-2*k(2))+(2*a(2)*k(2)-a(2)*k(1)-2*a(1)*k(1)+a(1)*k(2))^2)^(0.5));
if (eigenvalue(1)<1)&&(eigenvalue(1)>- 1)&&(eigenvalue(2)<1)&&(eigenvalue(2)>-1)
a(2)=a(2)+0.002;
end
end
if a(2)>0
a(2)=a(2)-0.002;
else
a(2)=0;
end
f2(i)=a(2);
f1(i)=a(1);
a(1)=a(1)+0.002;
end
figure(1)
plot(f1,f2,'--r')
axis([0,0.25,0,0.25])
hold on


B=15;
BER=10^(-4);
K=1.5/(logm(0.2/BER)); SNR=[10,10]; k=log2(1+K.*SNR); r1=10;
r2=12; x=0; y=1; z=1;
% b=[0,0];
% c=x+y*(sum(b));
% p=r.*k.*b-b.*c;


a(1)=0.001;
for i=1:300 a(2)=0.001;
for j=1:300
eigenvalue(1)=1-10/3*(2*a(1)*k(1)-a(1)*k(2)+2*a(2)*k(2)- a(2)*k(1))+10/3*((a(1)*(k(2)-2*k(1))*a(2)*(k(1)-2*k(2))+(2*a(2)*k(2)- a(2)*k(1)-2*a(1)*k(1)+a(1)*k(2))^2)^(0.5));
eigenvalue(2)=1-10/3*(2*a(1)*k(1)-a(1)*k(2)+2*a(2)*k(2)-a(2)*k(1))-10/3*((a(1)*(k(2)-2*k(1))*a(2)*(k(1)-2*k(2))+(2*a(2)*k(2)-a(2)*k(1)-2*a(1)*k(1)+a(1)*k(2))^2)^(0.5));
if (eigenvalue(1)<1)&&(eigenvalue(1)>- 1)&&(eigenvalue(2)<1)&&(eigenvalue(2)>-1)
a(2)=a(2)+0.002;
end
end
if a(2)>0
a(2)=a(2)-0.002;
else
a(2)=0;
end
f2(i)=a(2);
f1(i)=a(1);
a(1)=a(1)+0.002;
end
figure(1) 
plot(f1,f2,'-.*b')
axis([0,0.25,0,0.25])
B=15;
BER=10^(-4);
K=1.5/(logm(0.2/BER));
SNR=[10,8]; k=log2(1+K.*SNR); r1=10;
r2=12; x=0; y=1; z=1;
% b=[0,0];
% c=x+y*(sum(b));
% p=r.*k.*b-b.*c;


a(1)=0.001;
for i=1:300 a(2)=0.001;
for j=1:300
eigenvalue(1)=1-10/3*(2*a(1)*k(1)-a(1)*k(2)+2*a(2)*k(2)- a(2)*k(1))+10/3*((a(1)*(k(2)-2*k(1))*a(2)*(k(1)-2*k(2))+(2*a(2)*k(2)- a(2)*k(1)-2*a(1)*k(1)+a(1)*k(2))^2)^(0.5));
eigenvalue(2)=1-10/3*(2*a(1)*k(1)-a(1)*k(2)+2*a(2)*k(2)-a(2)*k(1))-10/3*((a(1)*(k(2)-2*k(1))*a(2)*(k(1)-2*k(2))+(2*a(2)*k(2)-a(2)*k(1)-2*a(1)*k(1)+a(1)*k(2))^2)^(0.5));
if (eigenvalue(1)<1)&&(eigenvalue(1)>- 1)&&(eigenvalue(2)<1)&&(eigenvalue(2)>-1)
a(2)=a(2)+0.002;
end
end
if a(2)>0
a(2)=a(2)-0.002;
else
a(2)=0;
end
f2(i)=a(2);
f1(i)=a(1);
a(1)=a(1)+0.002;
end
figure(1)
plot(f1,f2,'-g')
axis([0,0.25,0,0.25])
B=15;
BER=10^(-4);
K=1.5/(logm(0.2/BER));
SNR=[7,7]; k=log2(1+K.*SNR); r1=10;
r2=12; x=0; y=1; z=1;
% b=[0,0];
% c=x+y*(sum(b));
% p=r.*k.*b-b.*c;


a(1)=0.001;
for i=1:300 a(2)=0.001;
for j=1:300
eigenvalue(1)=1-10/3*(2*a(1)*k(1)-a(1)*k(2)+2*a(2)*k(2)- a(2)*k(1))+10/3*((a(1)*(k(2)-2*k(1))*a(2)*(k(1)-2*k(2))+(2*a(2)*k(2)- a(2)*k(1)-2*a(1)*k(1)+a(1)*k(2))^2)^(0.5));
eigenvalue(2)=1-10/3*(2*a(1)*k(1)-a(1)*k(2)+2*a(2)*k(2)-a(2)*k(1))-10/3*((a(1)*(k(2)-2*k(1))*a(2)*(k(1)-2*k(2))+(2*a(2)*k(2)-a(2)*k(1)-2*a(1)*k(1)+a(1)*k(2))^2)^(0.5));
if (eigenvalue(1)<1)&&(eigenvalue(1)>- 1)&&(eigenvalue(2)<1)&&(eigenvalue(2)>-1)
a(2)=a(2)+0.002;
end
end
if a(2)>0
a(2)=a(2)-0.002;
else
a(2)=0;
end
f2(i)=a(2);
f1(i)=a(1);
a(1)=a(1)+0.002;
end
figure(1)
plot(f1,f2,'-.y')
axis([0,0.25,0,0.25])
B=15;
BER=10^(-4);
K=1.5/(logm(0.2/BER)); SNR=[8,8]; k=log2(1+K.*SNR); r1=10;
r2=12; x=0; y=1; z=1;
% b=[0,0];
% c=x+y*(sum(b));
% p=r.*k.*b-b.*c;


a(1)=0.001;
for i=1:300 a(2)=0.001;
for j=1:300
eigenvalue(1)=1-10/3*(2*a(1)*k(1)-a(1)*k(2)+2*a(2)*k(2)- a(2)*k(1))+10/3*((a(1)*(k(2)-2*k(1))*a(2)*(k(1)-2*k(2))+(2*a(2)*k(2)- a(2)*k(1)-2*a(1)*k(1)+a(1)*k(2))^2)^(0.5));
eigenvalue(2)=1-10/3*(2*a(1)*k(1)-a(1)*k(2)+2*a(2)*k(2)-a(2)*k(1))-10/3*((a(1)*(k(2)-2*k(1))*a(2)*(k(1)-2*k(2))+(2*a(2)*k(2)-a(2)*k(1)-2*a(1)*k(1)+a(1)*k(2))^2)^(0.5));
if (eigenvalue(1)<1)&&(eigenvalue(1)>- 1)&&(eigenvalue(2)<1)&&(eigenvalue(2)>-1)
a(2)=a(2)+0.002;
end
end
if a(2)>0
a(2)=a(2)-0.002;
else
a(2)=0;
end
f2(i)=a(2);
f1(i)=a(1);
a(1)=a(1)+0.002;
end


figure(1)
plot(f1,f2,'om') 
axis([0,0.25,0,0.25])
legend('r1=8dB,r2=10dB','r1=10dB,r2=10dB','r1=10dB,r2=8dB','r1=7dB,r2=7dB','r1=8dB,r2=8dB')
xlabel('a1')
ylabel('a2')

结果:

相关推荐
woshilys13 分钟前
sql server 查询对象的修改时间
运维·数据库·sqlserver
Hacker_LaoYi13 分钟前
SQL注入的那些面试题总结
数据库·sql
建投数据1 小时前
建投数据与腾讯云数据库TDSQL完成产品兼容性互认证
数据库·腾讯云
孤亭远见1 小时前
COMSOL with Matlab
matlab
Hacker_LaoYi2 小时前
【渗透技术总结】SQL手工注入总结
数据库·sql
岁月变迁呀2 小时前
Redis梳理
数据库·redis·缓存
独行soc2 小时前
#渗透测试#漏洞挖掘#红蓝攻防#护网#sql注入介绍06-基于子查询的SQL注入(Subquery-Based SQL Injection)
数据库·sql·安全·web安全·漏洞挖掘·hw
你的微笑,乱了夏天3 小时前
linux centos 7 安装 mongodb7
数据库·mongodb
工业甲酰苯胺3 小时前
分布式系统架构:服务容错
数据库·架构
图南楠4 小时前
simulink离散传递函数得到差分方程并用C语言实现
matlab