⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c15_hmm2.m

📁 很多MATLAB的无线系统仿真实例。强烈推荐!
💻 M
字号:
% File: c15_hmm2.m
% Software given here is to accompany the textbook: W.H. Tranter, 
% K.S. Shanmugan, T.S. Rappaport, and K.S. Kosbar, Principles of 
% Communication Systems Simulation with Wireless Applications, 
% Prentice Hall PTR, 2004.
%
N = 100000;								% number of iterations
state = 'Good';							% initial state
P = [0.98 0.02; 0.05 0.95];			    % state transition matrix
B = [0.0005 0.1000];					
out = zeros(1,N);						% initialize matrix
errors = 0;
for i=1:N
   error = 0;							% initialize error counter
   y = rand(1);							% RV for state transition
   err = rand(1);						% RV for error given state
   if state=='Good'						% test for Good state
      if y<P(1,1)							
         state='Good';					% remain in Good state
         if err<B(1);					% test for error
            error = 1;					% record an error
         end   
      else									
         state='Bad ';					% transition to Bad state
         if err<B(2);					% test for error
            error = 1;					% record an error
         end            
      end
   else									% state = Bad
      if y<P(2,2);
         state='Bad ';					% remain in Bad state
         if err<B(2);					% test for error
            error = 1;					% record an error
         end   
      else
         state='Good';					% transition to Good state
         if err<B(1);					% test for error
            error = 1;					% record an error
         end   
      end
   end
   errors = errors + error;			    % increment error counter
end
PE = errors/N						    % calculate error proability
% End of script file.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -