该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
clc;
clear;
t=0:0.0001:1-0.0001;%时间步长
f=30;%载波
M=500;
m=4;%4相调制
fai=0:2*pi/m:2*pi;%相位分配
Carrier1=sin(2*pi*f*t+fai(1));%4种相位分别代表不同的值
Carrier2=sin(2*pi*f*t+fai(2));
Carrier3=sin(2*pi*f*t+fai(3));
Carrier4=sin(2*pi*f*t+fai(4));
P=length(t)/M;
randNum=rand(1,P);
Signal=zeros(1,length(t));
for i=1:P
if randNum(i)>=0.5
randNum(i)=1;
else
randNum(i)=0;
end
end
for j=0:P-1
for p=1:M
Signal(j*M+p)=randNum(j+1);
end
end
chuanToBing1=zeros(1,length(t));
chuanToBing2=zeros(1,length(t));
chuanToBing3=zeros(1,length(t));
chuanToBing4=zeros(1,length(t));
for i=1:P/log2(m)
if(randNum((i-1)*2+1)==0)&randNum((i-1)*2+2)==0
for j=1:2*M
chuanToBing1((i-1)*2*M+j)=1;
end
elseif(randNum((i-1)*2+1)==0)&randNum((i-1)*2+2)==1
for j=1:2*M
chuanToBing2((i-1)*2*M+j)=1;
end
elseif(randNum((i-1)*2+1)==1)&randNum((i-1)*2+2)==0
for j=1:2*M
chuanToBing3((i-1)*2*M+j)=1;
end
elseif(randNum((i-1)*2+1)==1)&randNum((i-1)*2+2)==1
for j=1:2*M
chuanToBing4((i-1)*2*M+j)=1;
end
end
end
s1=chuanToBing1.*Carrier1;
求各位大神指导
s2=chuanToBing2.*Carrier2;
s3=chuanToBing3.*Carrier3;
s4=chuanToBing4.*Carrier4;
psk=s1+s2+s3+s4;
%绘图
subplot(2,1,1);plot(t,Signal);axis([0 1 -0.1 1.1]);
title('The Input Digital Signal');xlabel('Time');grid
subplot(2,1,2);plot(t,psk);
title('The 4PSK Signal');xlabel('Time');grid;