clear ; close all; N=500; fs=200; Ts=1;
t=0:1/fs:N*Ts; fm=1/2*Ts; fc=4;
附录
%用正弦波产生方波
twopi_fc_t=2*pi*fm*t; %源信号 A=1; %幅值为1
phi=0; %相位偏移为0 x = A * cos(twopi_fc_t + phi); % 方波 am=1;
x(x>0)=am; x(x<0)=-1;
subplot(3,1,1); plot(t,x);
axis([0 5 -2 2]);
title('等概二进制信源'); grid on;%加边框
car=sin(2*pi*fc*t); %载波
psk=x.*car; %载波调制(相乘器) subplot(3,1,2); plot(t,psk);
axis([0 5 -2 2]); title('2PSK信号'); grid on;
subplot(3,1,3);
plot(abs(fft(psk)));%产生2psk信号的频谱 axis([0 100000 0 40000]); grid on;
title('2psk信号频谱');xlabel('f');
12