通信原理 课程设计 全.docx
《通信原理 课程设计 全.docx》由会员分享,可在线阅读,更多相关《通信原理 课程设计 全.docx(18页珍藏版)》请在冰点文库上搜索。
通信原理课程设计全
第一题
clear
echooff
t0=0.15;
ts=0.001;
fc=250;
snr=20;
fs=1/ts;
t=(0:
ts:
t0);
dt=0.01;
df=0.3;
snr_lin=10^(snr/10);
m=[ones(1,t0/(3*ts)),-2*ones(1,t0/(3*ts)),zeros(1,t0/(3*ts)+1)];
c=cos(2.*pi.*fc.*t);
u=[2+0.85*m].*c;
clf
figure
(1)%
(1)m(t)和u(t)的波形
subplot(2,1,1)
plot(t,m(1:
length(t)))
xlabel('Time')
title('基带信号m(t)')
subplot(2,1,2)
plot(t,u(1:
length(t)))
xlabel('Time')
title('调制信号u(t)')
[M,m,df1]=fftseq(m,ts,df);%
(2)m(t)和u(t)的频谱图
M=M/fs;
[U,u,df1]=fftseq(u,ts,df);
U=U/fs;
[C,c,df1]=fftseq(c,ts,df);
f=[0:
df1:
df1*(length(m)-1)]-fs/2;
figure
(2)
subplot(2,1,1)
plot(f,abs(fftshift(M)))
xlabel('frequency')
title('基带信号频谱M(f)')
subplot(2,1,2)
plot(f,abs(fftshift(U)))
xlabel('frequency')
title('调制信号频谱U(f)')
signal_power=sum(u.*u)*dt/(length(t).*dt);%(3)周期T0=t0,求已调信号的功率
signal_power
noise_power=signal_power/snr_lin;%(4)噪声功率
noise_power
noise_std=sqrt(noise_power);
n=noise_std*randn(1,length(u));
r=u+n;
figure(5)%(5)噪声n(t)和已调信号加噪声(u(t)+n(t))的波形;
subplot(2,1,1)%噪声时域显示
plot(t,n(1:
length(t)))
title('噪声信号')
subplot(2,1,2)%加噪调制信号时域显示
plot(t,r(1:
length(t)))
title('信号加噪声信号')
[N,n,df1]=fftseq(n,ts,df);%对噪声进行fft
N=N/fs;%频率采样
[R,r,df1]=fftseq(r,ts,df);%对最后的信号进行fft
R=R/fs;
figure(6)%(6)噪声n(t)和已调信号加噪声(u(t)+n(t))的频谱图;
subplot(2,1,1)%噪声频域显示
plot(f,abs(fftshift(N)))
axis([-20020000.15])
title('噪声信号频谱')
axis([00.15-33])
subplot(2,1,2)%加噪调制信号频域显示
plot(f,abs(fftshift(R)))
title('信号加噪声信号频谱')
axis([-50050000.15])
M文件
function[M,m,df]=fftseq(m,ts,df)
fs=1/ts;
n1=fs/df;
n2=length(m);
n=2^(max(nextpow2(n1),nextpow2(n2)));
M=fft(m,n);
m=[m,zeros(1,n-n2)];
df=fs/n;
第二题
clear
echooff
b=3000;
sn0=-20;
sn1=30;
ns=0.01;
N=(sn0:
ns:
sn1);
snrlin=10.^(N/10);
ct=b.*log2(1+snrlin.*(1/b));
clf
subplot(2,1,1)
plot(snrlin,ct)
xlabel('s/n0')
title('高斯信道容量')
clear
echooff
n1=25;
sn1=10.^(n1/10);
bs=10;
B=(3000:
bs:
300000);
b=1./B;
ct=B.*(log2(1+sn1.*b));
subplot(2,1,2)
plot(B,ct)
xlabel('B')
title('B无限增加时信道容量')
ct=(1/log
(2)*sn1)
ct=456.2202
第三题
clearall;
clf;
Tb=1;
f1=1000/Tb;
f2=f1+1/Tb;
phi=pi/4;
N=12000;
n=N/4;
t=0:
Tb/(n-1):
Tb;%t=0:
1/(n-1):
1;
T=0:
4*Tb/(N-1):
4*Tb;%T=0:
4*1/(N-1):
4*1;
s1=[cos(2*pi*f1*t+phi)cos(2*pi*f1*t+phi)cos(2*pi*f1*t+phi)cos(2*pi*f1*t+phi)];
s2=[cos(2*pi*f2*t+phi)cos(2*pi*f2*t+phi)cos(2*pi*f2*t+phi)cos(2*pi*f2*t+phi)];%assumethetransmitsignalis"1010",ie.u2u1andu2
a=[cos(2*pi*f2*t+phi)cos(2*pi*f1*t+phi)cos(2*pi*f2*t+phi)cos(2*pi*f1*t+phi)];%aisthereceivedsignal
b=a.*s1;
c=a.*s2;
forj=1:
4
fori=1:
n;
d((j-1)*n+i)=sum(b((j-1)*n+1:
(j-1)*n+i));
end;
end;
%求积分
forj=1:
4
fori=1:
n;
e((j-1)*n+i)=sum(c((j-1)*n+1:
(j-1)*n+i));
end;
end;
%求积分
forj=1:
4;
ifd(j*n)>e(j*n);
f((j-1)*n+1:
j*n)=zeros(1,n);%输出0
else
f((j-1)*n+1:
j*n)=ones(1,n);%输出1
end;
end;
%比较器
figure
(1)
plot(T,a);
xlabel('时间');
ylabel('幅度');
title('figurea');
holdon
figure
(2)
subplot(2,1,1);
plot(T,b);
ylabel('幅度');
title('figureb');
subplot(2,1,2)
plot(T,c);
ylabel('幅度');
xlabel('时间');
ylabel('幅度');
title('figurec');
holdon
figure(3)
subplot(3,1,1);
plot(T,d);
ylabel('幅度');
title('figured');
subplot(3,1,2);
plot(T,e);
ylabel('幅度');
title('figuree');
subplot(3,1,3);
plot(T,f);
xlabel('时间');
ylabel('幅度');
title('figuref');
第四题
n=15;
k=5;
g=[10100110111];
m=mMatrix(k);
fori=0:
2^k-1
nkm=[m(i+1,:
)zeros(1,n-k)];
[qr]=deconv(nkm,g);
r=mod(r,2);
len_r=length(r);
r=[zeros(1,n-len_r)r];
c(i+1,:
)=mod(nkm+r,2)
end;
fori=1:
2^k
weight(i)=sum(c(i,:
));
end;
minW=weight
(2)
fori=3:
2^k;
ifweight(i)minW=weight(i);
else
end;
end;
c=
000000000000000
000010100110111
000101001101110
000111101011001
001000111101011
001010011011100
001101110000101
001111010110010
010001111010110
010011011100001
010100110111000
010110010001111
011001000111101
011011100001010
011100001010011
011110101100100
100001010011011
100011110101100
100100011110101
100110111000010
101001101110000
101011001000111
101100100011110
101110000101001
110000101001101
110010001111010
110101100100011
110111000010100
111000010100110
111010110010001
111101011001000
111111111111111
minW=
7
clearall;
n=15;
k=5;
g=[10100110111];
m=[10000
01000
00100
00010
00001];
fori=1:
5;
nkm=[m(i,:
)zeros(1,n-k)];
[qr]=deconv(nkm,g);
r=mod(r,2);
len_r=length(r);
r=[zeros(1,n-len_r)r];
c(i,:
)=mod(nkm+r,2);
end;
G=c
H=[(G(:
k+1:
n))'eye(n-k,n-k)]
B=[110010100110110];
S=mod(B*H',2)
G=
100001010011011
010001111010110
001000111101011
000101001101110
000010100110111
H=
110101000000000
011010100000000
111000010000000
011100001000000
001110000100000
110010000010000
101100000001000
010110000000100
111110000000010
101010000000001
S=
0101001100
M文件
functionm=mMatrix(k)
%
m(1,:
)=[00000];
m(2,:
)=[00001];
fori=2:
2^k-1;
t=i;
e=1;
d=2^e;
a=[00000];
while1;
ift>d;
e=e+1;
d=2^e;
else
break;
end;
end;
ift<2^e;
e=e-1;
end;
while1;
ift-2^e==0;
a(k-e)=1;
break;
end;
ift-2^e>0;
a(k-e)=1;
t=t-2^e;
e=e-1;
else
a(k-e)=0;
e=e-1;
end;
end;
m(i+1,:
)=a;
a=[00000];
end;