Markov的仿真
Posted fpga&matlab
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
以上是关于Markov的仿真的主要内容,如果未能解决你的问题,请参考以下文章