MATLAB
一、
t=0:1/1e3:0.999;
a=randint(1,10,2);
g=ones(1,100);
g=[g,g,g,g,g,g,g,g,g,g];
s=a(ceil(10*t+0.01)).*g.*cos(2*pi*100*t);
subplot(2,1,1);
plot(t,a(ceil(10*t+0.01)));
axis([0,1,0,1.2]);
subplot(2,1,2);
plot(t,s);
二、
t=0:1/1e3:0.999;
df=10;
a=randint(1,10,2);
m=2*a(ceil(10*t+0.01))-1;
s=cos(2*pi*(100+m*df).*t);
f=1000*(0:256)/512;
S=fft(s,512);
Pss=S.*conj(S)/512;
subplot(3,1,1);
plot(t,a(ceil(10*t+0.01)));
axis([0,1,0,1.2]);
subplot(3,1,2);
plot(t,s);
subplot(3,1,3);
plot(f,Pss(1:257));
三、
M=2;
t=0:0.001:0.999;
m=randint(10,1,M)';
m=m(ceil(10*t+0.01));
s=cos(2*pi*100*t+m/M);
f=1000*(0:256)/512;
S=fft(s,512);
Pss=S.*conj(S)/512;
subplot(3,1,1);
plot(t,m);
axis([0,1,min(m)-0.2,max(m)+0.2]);
subplot(3,1,2);
plot(t,s);
subplot(3,1,3);
plot(f,Pss(1:257));
四、
%- 2DPSK 调制与解调
%---------------------------------------------------
%>>>>>>>>>>>>>>>>>>Initial_Part>>>>>>>>>>>>>>>>>>>>>
%---------------------------------------------------
function y=dpsk2()
fs = 30000;
Time_Hold_On = 0.1;
Num_Unit = fs * Time_Hold_On;
High_Level = ones ( 1, Num_Unit );
Low_Level = zeros ( 1, Num_Unit );
w = 300;
A = 1;
%---------------------------------------------------
%>>>>>>>>>>>>>>>>>>Initial_The_Signal>>>>>>>>>>>>>>>
%---------------------------------------------------
Sign_Set = [0,1,1,0,1,0,0,1]
Lenth_Of_Sign = length ( Sign_Set );
st = zeros ( 1, Num_Unit * Lenth_Of_Sign );
sign_orign = zeros ( 1, Num_Unit * Lenth_Of_Sign );
sign_result = zeros ( 1, Num_Unit * Lenth_Of_Sign );
t = 0 : 1/fs : Time_Hold_On * Lenth_Of_Sign - 1/fs;
%---------------------------------------------------
%>>>>>>>>>>>Generate_The_Original_Signal>>>>>>>>>>>>
%---------------------------------------------------
for I = 1 : Lenth_Of_Sign
if Sign_Set(I) == 1
sign_orign( (I-1)*Num_Unit + 1 : I*Num_Unit) = High_Level;
else
sign_orign( (I-1)*Num_Unit + 1 : I*Num_Unit) = Low_Level;
end
end
%---------------------------------------------------
%>>>>>>>>>>>>>>>>>>Modulation_Part>>>>>>>>>>>>>>>>>>
%---------------------------------------------------
for I = 1 : Lenth_Of_Sign
if Sign_Set(I) == 1
st( (I-1)*Num_Unit + 1 : I*Num_Unit) = A * cos ( 2 * pi * w * t( (I-1)*Num_Unit + 1 : I*Num_Unit ) + ( pi / 2 ) );
else
st( (I-1)*Num_Unit + 1 : I*Num_Unit) = A * cos ( 2 * pi * w * t( (I-1)*Num_Unit + 1 : I*Num_Unit ) );
end
end
figure
subplot ( 2, 1, 1 )
plot(t, sign_orign);
axis( [ 0 , Time_Hold_On *( Lenth_Of_Sign + 1), - (A / 2), A + (A / 2) ] );
title ( '原始信号' );
grid
subplot ( 2, 1, 2 );
plot ( t, st );
axis( [ 0 , Time_Hold_On *( Lenth_Of_Sign + 1), - 3*(A / 2), 3*(A / 2) ] );
title ( '调制后的信号' );
grid
%---------------------------------------------------
%>>>>>>>>>>>>>>>>>>相乘>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
%---------------------------------------------------
dt = st .* cos ( 2 * pi * w * t );
figure
subplot(2,1,1)
plot ( t, dt );
axis(