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

📄 ip_06_06.m

📁 这是通信系统仿真的第六章的例题的仿真程序代码!挺好的
💻 M
字号:
% MATLAB script for Illustrative Problem 6, Chapter 6.
echo on
N=52;					
noise_var=0.25;
sigma=sqrt(noise_var);			% standard deviation of the noise
for i=1:N,				% generate data sequence
   if (rand<0.5), 
      I(i)=1;
   else
      I(i)=-1;
   end;
   echo off ;
end;
echo on ;
% for channel1:
A=1;
B=[0.1 -0.25 1 -0.25 0.1];
rec_sig1=filter(B,A,I);    		% the received signal without noise for channel 1
rec_sig1=rec_sig1([3:N]);  		% to compensate for the delay in filtering
for i=1:N-2,
   noise(i)=gngauss(sigma);
   echo off ;
end;
echo on ;
y1=rec_sig1+noise;	   		% received signal with noise for channel 1
% for channel 2:
A=1;
B=[-0.2 0.5 1 0.5 -0.2];
rec_sig2=filter(B,A,I);    		% the received signal without noise for channel 2
rec_sig2=rec_sig2(3:N);	   		% to compensate for the delay in filtering 
for i=1:N-2,
   noise(i)=gngauss(sigma);
   echo off ;
end;
echo on ;
y2=rec_sig2+noise;         		% received signal with noise for channel 2

i=find(rec_sig1>0)
rec_sig1_1=rec_sig1(i)
i=find(rec_sig1<=0)
rec_sig1_0=rec_sig1(i)
i=find(rec_sig1>0)
y1_1=y1(i)
i=find(rec_sig1<=0)
y1_0=y1(i)

i=find(rec_sig2>0)
rec_sig2_1=rec_sig2(i)
i=find(rec_sig2<=0)
rec_sig2_0=rec_sig2(i)
i=find(rec_sig2>0)
y2_1=y2(i)
i=find(rec_sig2<=0)
y2_0=y2(i)
figure(1);

plot(rec_sig1_1,0,'o',rec_sig1_0,0,'x')
axis([-2 2 0 1]);
hgsave('fig_ip0606_1');
figure(2);
plot(y1_1,0,'o',y1_0,0,'x')
axis([-2 2 0 1]);
hgsave('fig_ip0606_2');

figure(3);
plot(rec_sig2_1,0,'o',rec_sig2_0,0,'x')
axis([-2 2 0 1]);
hgsave('fig_ip0606_3');
figure(4);
plot(y2_1,0,'o',y2_0,0,'x')
axis([-2 2 0 1]);
hgsave('fig_ip0606_4');

% plotting commands follow

⌨️ 快捷键说明

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