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

📄 untitled2.m

📁 是关于通信仿真的几个程序
💻 M
字号:
echo on;
t0=.15;
ts=0.001;
fc=250;
snr=20;
fs=1/ts;
df=0.3;
t=[0:ts:t0];
snr_lin=10^(snr/10);
m=[ones(1,t0/(3*ts)),-2*ones(1,t0/(3*ts)),zeros(1,t0/(3*ts)+1)];
c=cos(2*pi*fc.*t);
u=m.*c;
[M,m,df1]=fftseq(m,ts,df);
M=M/fs;
[U,u,df1]=fftseq(u,ts,df);
U=U/ts;
[C,c,df1]=fftseq(c,ts,df);
f=[0:df1:df1*(length(m)-1)]-fs/2;
signal_power=spower(u(1:length(t)));
noise_power=signal_power/snr_lin;
noise_std=sqrt(noise_power);
noise=noise_std*randn(1,length(u));
r=u+noise;
[R,r,df1]=fftseq(r,ts,df);
R=R/fs;
pause;
signal_power;
pause;
clf;
subplot(2,2,1);
plot(t,m(1:length(t)));
xlabel('Time');
title('The message signal');
pause;
subplot(2,2,2);
plot(t,c(1:length(t)));
xlabel('Time');
title('The carrier');
pause;
subplot(2,2,3);
plot(t,u(1:length(t)))
xlabel('Time');
title('The modulated signal');
pause;
subplot(2,1,1);
plot(f,abs(fftshift(M)));
xlabel('Frequency');
title('Spectrum of the message Signal');
subplot(2,1,2);
plot(f,abs(fftshift(U)));
title('Spectrum of the modulated Signal');
xlabel('Frequency');
pause;
subplot(2,1,1);
plot(t,noise(1:length(t)));
title('noise sample');
xlabel('Time');
pause;
subplot(2,1,2);
plot(t,r(1:length(t)));
title('Signal and noise');
xlabel('Time');
pause;
subplot(2,1,1);
plot(f,abs(fftshift(U)));
title('Signal spectrum');
xlabel('Frequency');
subplot(2,1,2);
plot(f,abs(fftshift(R)));
title('Signal and noise spectrum');
xlabel('Frequency');

⌨️ 快捷键说明

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