📄 ppm_th_transmitter.m
字号:
%function [bits,thcode,stx,ref]=ppm_th_transmitter
%模拟完整的ppm_th发射机
%函数返回值
% bits 数据流
% thcode 跳时码序列
% stx 总的信号序列
% ref 未经调制的参考信号
function [bits,thcode,stx,ref]=ppm_th_transmitter
%step0 input parameters
pow=-30; %平均发射功率 [dBm]
fc=50e9; %抽样频率 [Hz]
numbits=1000; %信源产生的bit数
ts=10e-9; %脉冲重复周期 [s]
ns=5; %重复编码次数
tc=1e-9; %跳时码片长度 [s]
nh=10; %跳时码的势,即最大值
np=5; %跳时码的周期个数
tm=0.5e-9; %脉冲持续时间
tau=0.25e-9; %脉冲成形因子,越大脉冲越宽
dppm=0; %ppm调制时间偏移量
g=0; %g=0 no graphical output;
%step1 simulating transmission chain
%binary sourse
bits=genrandbits(numbits);
%重复编码
repbits=repcode(bits,ns);
%thcode
thcode=genth(nh,np);
%ppm+th调制
[ppmthseq,thseq]=ppm_th(repbits,fc,tc,ts,dppm,thcode);
%脉冲成形
power=(10^(pow/10))/1000; %平均发射功率 瓦
ex=power*ts; %单个脉冲能量
w0=gausspulse(fc,tm,tau); %能量标准化后的脉冲波形
wtx=w0.*sqrt(ex); %脉冲波形
sa=conv(ppmthseq,wtx); %调制信号输出
sb=conv(thseq,wtx); %未加ppm调制的参考跳时调制脉冲序列
% output generation
l=(floor(ts*fc))*ns*numbits;
stx=sa(1:l);
ref=sb(1:l);
%step2 graphical output
if g
F=figure(1);
set(F,'position',[32 223 951 420]);
tmax=numbits*ns*ts;
time=linspace(0,tmax,length(stx));
p=plot(time,stx);
set(p,'linewidth',[2]);
ylow=-1.5*abs(min(wtx));
yhigh=1.5*max(wtx);
axis([0 tmax ylow yhigh]);
ax=gca;
set(ax,'fontsize',12);
x=xlabel('Time [S]');
set(x,'fontsize',14);
y=ylabel('Amplitude [V]');
set(y,'fontsize',14);
for j=1:numbits
tj=(j-1)*ns*ts;
l1=line([tj tj],[ylow yhigh]);
set(l1,'color',[0 0 0],'linestyle','--','linewidth',[2]);
for k=0:ns-1
if k>0
tn=tj+k*nh*tc;
l2=line([tn tn],[ylow yhigh]);
set(l2,'color',[0.5 0.5 0.5],'linestyle','-.','linewidth',[2]);
end
for q=1:nh-1
th=tj+k*nh*tc+q*tc;
l3=line([th th],[0.8*ylow 0.8*yhigh]);
set(l3,'color',[0 0 0],'linestyle',':','linewidth',[1]);
end
end
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -