pr5_9.m
来自「Spread Spectrum and CDMA Principles and 」· M 代码 · 共 27 行
M
27 行
%Problem 5.9;
%Simulates and displays different modulation modes of discrete signals;
clear all; close all;
Per=0, %for aperiodic signal put this equal to zero, for periodic - one;
N=8; %length of discrete signal;
t=[0:200*N-1]/100; %time scale;
Chip=[ones(1,100);sin(pi*t(1:100));exp(-16*(t(1:100)-0.5).^2)]; %three chip shapes: rectangular, half sine, and bell-shaped;
Ch=Chip(2,:); %select chip form;
CEAPSK=(unidrnd(3,1,N)-1).*exp(i*pi*unidrnd(4,1,N)/2); %random APSK code sequence: real amplitudes 0,1,2, phases as in QPSK;
CEBPSK=2*unidrnd(2,1,N)-3; %random code sequence of BPSK;
CEQPSK=exp(i*pi*unidrnd(4,1,N)/2); %random code sequence of QPSK;
CS=[CEAPSK;CEBPSK;CEQPSK]; %matrix of all code sequnces;
f0=5; car=exp(i*2*pi*t*f0); %carrier frequency;
YL={'s(t), APSK','s(t), BPSK','s(t), QPSK','s(t), FSK'}; %labels for plots;
if Per==0 Perstr='Aperiodic'; else Perstr='Periodic'; end; %preparation for title;
TT=[Perstr,' discrete signals']; %string for a title;
for k=1:3 %in the loop all the same operations are done for 3 first types of discrete signals;
CSk=CS(k,:); CSk=kron(CSk,Ch); CSk=[CSk,Per*CSk]; SI=imag(CSk.*car); M=max(SI); %forming bandpass discrete signal;
subplot(4,1,k); plot(t,SI); ylabel(YL(k)); ylim([-1.2,1.2]*M); grid; %plotting signal;
if k==1 title(TT); end;
end;
CEFSK=unidrnd(N-2,1,N)-1; CEFSK=exp(i*2*pi*kron(CEFSK,t(1:100))); %random frequency code sequence for FSK;
CEFSK=[CEFSK,Per*CEFSK]; SI=imag(kron(ones(1,2*N),Ch).*CEFSK.*car); %FSK bandpass signal;
subplot(4,1,4); plot(t,SI); ylabel(YL(4)); ylim([-1.2,1.2]); grid; %plotting FSK signal;
xlabel('t/\delta');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?