Markov的仿真
% main.m
% 主程序:對于不同的K,N值作折線圖。參數FrameNum為幀的最大個數。
% by 姜晶
% 2013.4.10
clear;
FrameNum=7;
X=0:1:FrameNum;
[F(1,:) Y(1,:)]=Markov(17,20,FrameNum);
[F(2,:) Y(2,:)]=Markov(12,20,FrameNum);
[F(3,:) Y(3,:)]=Markov(7,20,FrameNum);
[F(4,:) Y(4,:)]=Markov(15,15,FrameNum);
[F(5,:) Y(5,:)]=Markov(10,15,FrameNum);
[F(6,:) Y(6,:)]=Markov(5,15,FrameNum);
?
%仿真和分析畫在一起(平均選到時隙的節點數)
figure(1);
plot(X,Y(1,:),'k-o');
hold on;
plot(X,simulation(17,20,FrameNum),'k:.');
hold on;
plot(X,Y(2,:),'k-o');
hold on;
plot(X,Y(3,:),'k-o');
hold on;
plot(X,Y(4,:),'k-o');
hold on;
plot(X,Y(5,:),'k-o');
hold on;
plot(X,Y(6,:),'k-o');
hold on;
plot(X,simulation(12,20,FrameNum),'k:.');
hold on;
plot(X,simulation(7,20,FrameNum),'k:.');
hold on;
plot(X,simulation(15,15,FrameNum),'k:.');
hold on;
plot(X,simulation(10,15,FrameNum),'k:.');
hold on;
plot(X,simulation(5,15,FrameNum),'k:.');
xlabel('n(Number of frames)');
ylabel('Average number of nodes acquiring a time slot within n frames');
legend('Analysis','Simulation');
grid on;
%模型分析圖(平均選到時隙的節點數)
figure(2)
plot(X,Y(1,:),'k-o');
hold on;
plot(X,Y(2,:),'k-*');
hold on;
plot(X,Y(3,:),'k-s');
hold on;
plot(X,Y(4,:),'k-d');
hold on;
plot(X,Y(5,:),'k-^');
hold on;
plot(X,Y(6,:),'k-v');
hold on;
xlabel('n(Number of frames)');
ylabel('Average number of nodes acquiring a time slot within n frames');
legend('N=20,K=17','N=20,K=12','N=20,K=7','N=15,K=15','N=15,K=10','N=15,K=5');
grid on;
%模型分析圖(全部節點都選到時隙的概率)
figure(3)
plot(X,F(1,:),'k-o');
hold on;
plot(X,F(2,:),'k-*');
hold on;
plot(X,F(3,:),'k-s');
hold on;
plot(X,F(4,:),'k-d');
hold on;
plot(X,F(5,:),'k-^');
hold on;
plot(X,F(6,:),'k-v');
hold on;
xlabel('n(Number of frames)');
ylabel('\itF^all_n');
legend('N=20,K=17','N=20,K=12','N=20,K=7','N=15,K=15','N=15,K=10','N=15,K=5');
grid on;
d126
?
總結
- 上一篇: 求带便函数权值的最短路径
- 下一篇: 蚁群算法搜索个体适应度值