双极性非归零码基带信号波形及其眼图程序代代码:
clear all;
close all;
Ts = 1;
N_sample = 128;
eye_num = 5;
alpha = 1;
N_data = 10000;
dt = Ts/N_sample;
t = -3*Ts:dt:3*Ts;
%产生双极性数字信号
d = sign(randn(1,N_data));
dd = sigexpand(d.N_sample);
%基带系统冲击响应
ht = sinc(t/Ts).*(cos(alpha*pi*t/Ts))./(1-4*alpha^2 * t.^2/Ts^2+eps);
st = conv(dd,ht);
tt = -3*Ts:dt:(N_data+3)*N_sample*dt-dt;
figure(1)
subplot(211)
plot(tt,st);
axis([0 20 -1.2 1.2]);xlabel('t/Ts');ylabel('基带信号');
subplot(212)
%画眼图
ss = eros(1,eye_num*N_sample);
ttt = 0:dt:eye_num*N_sample*dt-dt;
for k = 3:50
ss = st(k*N_sample+1:(k*eye_num)*N_sample);
drawnow;
plot(ttt,ss);hold on;
end
xlabel('t/Ts');ylabel('基带信号眼图')
需要注意的是,程序中用到sigexpand,因此要重建一个m文件,命名为:sigexpand.m
代码如下:
在这里插入代码片% sigexpand.m
%
% Simulation program to expand the symbol sequence
%
% Programmed by Y.S. Cui and H.Harada
%
function [out]=sigexpand(d,M)
N=length(d);%基带信号码元长度
out=zeros(M,N);%矩阵M为采样点 N为基带信号码元数量
out(1,:)=d;%将零矩阵第一行换成基带信号中的8个码元
out=reshape(out,1,M*N);% 1行 m*n 列
运行结果:
来源:https://blog.csdn.net/qq_37369201/article/details/100540111