资源简介
Matlab 强大之处在于它可以用编程语言绘制想要模拟的系统最终输出的图形,通过 Matlab 编程 MSK 系统,可以得到各环节的图形,通过对图形的分析可以得出MSK系统的特点及性能
代码片段和文件信息
n=10000;
count=100;
N=n/count; %N=100
r=rand(1N-1); % 产生一个行向量,共9999个
for i=1:N-1
if (r(i)>=0.5) r(i)=1;
else r(i)=-1; end;
end; %将这9999个数整数化为1,-1
for i=1:n-count % 取9900个
R(i)=r(((i-1)-mod((i-1)count))/count+1); end; %
a(1)=1;
for i=2:N
if r(i-1)==1 a(i)=-a(i-1);
else a(i)=a(i-1);
end;
end;
for i=1:n
A(i)=a(((i-1)-mod((i-1)count))/count+1);
end;
for i=1:N
if(mod(i2))
l(i)=a(i);
l(i+1)=a(i);
else q(i)=a(i);
q(i-1)=a(i);
end;
end;
for i=1:n
I(i)=l(((i-1)-mod((i-1)count))/count+1);
end;
for i=1:n
Q(i)=q(((i-1)-mod((i-1)count))/count+1);
end;
ts=0.0001;
Ts=ts*count;
fs=1/ts;
fc=5/(2*Ts);
t0=Ts*N-ts;
f=1/(4*Ts);
df=0.3;
tI=[-Ts:ts:t0-Ts];
tQ=[0:ts:t0];
tQ_R=[0:ts:t0-Ts];
c=2*pi*f;
u=I.*cos(c*tI);
v=Q.*sin(c*tQ);
U=u.*cos(2*pi*fc*tI);
V=v.*sin(2*pi*fc*tQ);
for i=count+1:n
W(i)=U(i)+V(i-count);
end;
figure
subplot(411);
plot(tQ_RR‘k‘);
axis([-Ts0.1-22]);
title(‘数字信号‘);
grid on
subplot(412);
plot(tIA‘k‘);axis([-Ts0.1-22]);
title(‘差分编码后的信号‘);
grid on
subplot(413);
plot(tII‘k‘);
axis([-Ts0.1-22]);
title(‘同相调制信号I‘);
grid on
subplot(414); plot(tQQ‘k‘);axis([-Ts0.1-22]);
title(‘正交调制信号Q‘);
grid on
figure
subplot(311);
plot(tIU‘k‘);
axis([-Ts0.1-22]);
title(‘Icos(wct)cos(wt)‘);
grid on
subplot(312);
plot(tQV‘k‘);
axis([-Ts0.1-22]);
title(‘Qsin(wct)sin(wt)‘);
grid on
subplot(313);
plot(tIW‘k‘);
axis([-Ts0.1-22]);
title(‘MSK信号‘);
grid on
noise=0.15*randn(1n);
S=W+noise;
[S1sdf1]=fftSeq(Stsdf);
S1=S1/fs;
f=[0:df1:df1*(length(s)-1)]-fs/2;
n_cutoff=100;
H=zeros(size(f));
for i=floor((fc-n_cutoff)/df1):floor((fc+n_cutoff)/df1) H(i)=1;
end;
for i=(65536-floor((fc-n_cutoff)/df1)):-1:(65536-floor((fc+n_cutoff)/df1)) H(i)=1;
end;
DEM=S1.*H;
dem=real(ifft(DEM))*fs;
dm=dem(1:length(tQ));
ds1=dm.*cos(2*pi*fc*tQ+pi*tQ/(2*Ts));
ds2=dm.*cos(2*pi*fc*tQ-pi*tQ/(2*Ts));
[DW1wwdf1]=fftseq(ds1tsdf);
[DW2wwdf1]=fftseq(ds2tsdf);
DW1=DW1/fs;
DW2=DW2/fs;
n_cutoff1=floor(200/df1);
f1=[0:df1:df1*(length(ww)-1)]-fs/2;
H1=zeros(size(f1));
H1(1:n_cutoff1)=2*ones(1n_cutoff1);
H1(length(f1)-n_cutoff1+1:length(f1))=2*ones(1n_cutoff1);
DEM1=H1.*DW1;
DEM2=H1.*DW2;
s1=real(ifft(DEM1))*fs;
s11=s1(1:length(tQ));
s2=real(ifft(DEM2))*fs;
s22=s2(1:length(tQ));
for i=1:n
if (s11(i)>=0.95)||(s11(i)<=-0.95)sa(i)=-1;
else sa(i)=1;
end;
end;
for i=1:n
if (s22(i)>=0.95)||(s22(i)<=-0.95)sb(i)=1;
else sb(i)=-1;
end;
end;
- 上一篇:电子商务网站开发项目计划书.mpp
- 下一篇:脑电波MATLAB分析代码
评论
共有 条评论