T = 1; fs = 100; N = 100; nrz = ones(N,1); % NRZ pulse %nrz = [ones(N/2,1);zeros(N/2,1)]; % RZ %nrz = [ones(N/2,1);-ones(N/2,1)]; % Manchester %nrz = sin(pi*[0:N-1]/N); % HS nrzmf = flipud(nrz); rpnrz = conv(nrz,nrzmf); Lrpnrz = length(rpnrz); n = [-12*N:12*N].'+1e-7; a = 0.1; rtrc = (sin(pi*(1-a)*n/N)+4*a*n.*cos(pi*(1+a)*n/N)/N)./(pi*n.*(1-(4*a*n/N).^2)); rtrcmf = flipud(rtrc); rprtrc = conv(rtrc,rtrcmf); Lrprtrc = length(rprtrc); L = 100; syms = randn(L,1); syms = (syms>0)-(syms<=0); imp_train = zeros(N*L,1); imp_train(1:N:end) = syms; % Impulse train z_nrz = conv(imp_train,rpnrz); % MF output for NRZ pulse z_rtrc = conv(imp_train,rprtrc); % MF output for RTRC pulse % Remove convolution tails z_nrz(1:(Lrpnrz-1)/2) = []; z_nrz(end-(Lrpnrz-1)/2+[1:(Lrpnrz-1)/2]) = []; z_rtrc(1:(Lrprtrc-1)/2) = []; z_rtrc(end-(Lrprtrc-1)/2+[1:(Lrprtrc-1)/2]) = []; % Throw away a few symbol period at the beginning and end z_nrz(1:12*N) = []; z_nrz(end-12*N+[1:12*N]) = []; z_rtrc(1:12*N) = []; z_rtrc(end-12*N+[1:12*N]) = []; %return; %load eye_data t0 = T*fs; % Number of samples per period figure(1); clf; t = [0:length(z_nrz)-1]/t0; c = cos(2*pi*t); s = sin(2*pi*t); Znrz = reshape(z_nrz(t0/2+1:end-t0/2),t0,(length(z_nrz)-t0)/t0); subplot(211);plot(t(1:40*t0),z_nrz(1:40*t0)); grid on; hold on; plot(t(1:t0:40*t0),z_nrz(1:t0:40*t0),'or'); hold off; xlabel('Time (sec)'); title('Matched Filter Output (Samples in Red Circles)'); subplot(223);plot(t(1:t0)-T/2,Znrz); grid on; title('Eye Diagram'); xlabel('Time (sec)'); subplot(224);plot3(c(1:40*t0),s(1:40*t0),z_nrz(1:40*t0)); grid on; title('Cylindrical Eye Diagram'); %print -djpeg95 -r75 eye_stuff_nrz.jpg pause; t = [0:length(z_rtrc)-1]/t0; c = cos(2*pi*t); s = sin(2*pi*t); Zrtrc = reshape(z_rtrc(t0/2+1:end-t0/2),t0,(length(z_rtrc)-t0)/t0); subplot(211);plot(t(1:40*t0),z_rtrc(1:40*t0)); grid on; hold on; plot(t(1:t0:40*t0),z_rtrc(1:t0:40*t0),'or'); hold off; xlabel('Time (sec)'); title('Matched Filter Output (Samples in Red Circles)'); subplot(223);plot(t(1:t0)-T/2,Zrtrc); grid on; title('Eye Diagram'); xlabel('Time (sec)'); subplot(224);plot3(c(1:40*t0),s(1:40*t0),z_rtrc(1:40*t0)); grid on; title('Cylindrical Eye Diagram'); %print -djpeg95 -r75 eye_stuff_rtrc.jpg figure(2); clf; subplot(311); plot(nrz); grid on; subplot(312); plot(nrzmf); grid on; subplot(313); plot(rpnrz); grid on; pause; subplot(311); plot(rtrc); grid on; subplot(312); plot(rtrcmf); grid on; subplot(313); plot(rprtrc); grid on;