clear ;
close all;
fs=8e5; %抽样频率
fm=20e3; %基带频率
n=2*(6*fs/fm);
final=(1/fs)*(n-1);
fc=2e5; % 载波频率
t=0:1/fs:(final);
Fn=fs/2; %耐奎斯特频率
%用正弦波产生方波
twopi_fc_t=2*pi*fm*t;
A=1;
phi=0;
x = A * cos(twopi_fc_t + phi);
% 方波
am=1;
x(x>0)=am;
x(x<0)=-1;
figure(1)
plot(t,x);
axis([0 2e-4 -2 2]);
title('等概二进制信源');
grid on;
car=sin(2*pi*fc*t); %载波
psk=x.*car; %载波调制
figure(2)
plot(t,psk);
axis([0 200e-6 -2 2]);
title('2PSK信号');
grid on;
figure(3);
plot(abs(fft(psk)));%产生2psk信号的频谱
grid on;
title('2psk信号频谱');xlabel('f');