📄 am-dem.m
字号:
echo on
t0=.15;
ts=0.001;
fc=250;
a=0.85;
fs=1/ts;
t=[0:ts:t0];
df=0.25;
m=[ones ( 1, t0/( 3*ts ) ), -2*ones( 1, t0/( 3ts ) ),zeros ( 1, t0/( 3*ts )+1) ]
c=cos(2*pi*fc.*t);
m_n=m/max(abs(m));
[M,m,df1]=fftseq(m,ts,df);
f=[0:df1:df1*(length(m)-1)]-fs/2;
u=(1+a*m_n).*c;
[U,u,df1]=fftseq(u,ts,df);
env=env_phas(u);
dem1=2*(env-1)/a;
signal_power=power(u(1:length(t)));
noise_power=signal_power/100;
noise_std=sqrt(noise_power);
noise=noise_std*randn(1,length(u));
r=u+noise;
[R,r,df1]=fftseq(r,ts,df);
env_r=env_phas(r);
dem2=2*(env_r-1)/a;
pause
subplot (2,1,1)
plot(t,m (1:length(t)))
axis([0 0.15 -2.1 2.1])
xlabel('Time')
title('The message signal')
pause
clf
subplot (2,1,2)
plot (t,u(1:length(t)))
axis ([0 0.15 -2.1 2.1])
xlabel ('Time')
title ('The modulated signal')
pause
clf
subplot (2,1,1)
plot(t,u (1:length(t)))
axis ([0 0.15 -2.1 2.1])
xlabel ('Time')
title('The modulated signal')
subplot(2,1,2)
plot(t,env (1:length(t)))
xlabel('Time')
title('Envelope of the modulated signal')
pause
clf
subplot(2,1,1)
plot(t, m(1: length (t)))
axis([0 0.15 -2.1 2.1])
xlabel('Time')
title('The message signal')
subplot (2,1,2)
plot (t,dem1 (1:length(t)))
xlabel ('Time')
title ('The demodulated signal')
pause
clf
subplot (2,1,1)
plot (t,m(1:length(t)))
axis ([0 0.15 -2.1 2.1])
xlabel ('Time')
title ('The message signal')
subplot (2,1,2)
plot (t,dem2(1:length(t)))
xlabel ('Time')
title ('The demodulated signal in the presence of noise')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -