Eye diagram: Redefining a variable?
10 views (last 30 days)
Show older comments
I'm doing a MATLAB exercise to generate eye diagrams of different digital waveforms for a digital comm. course. The program is written in the text book, I just need to understand this one command:
yrz = yrz(1:end-Tau+1);
The whole program:
%(pnrz.m)
%generating a rectangular pulse of width T
function pout=prect(T);
pout=ones(1,T);
end
%(prz.m)
% genrating a rectangular pulse of width T/2
function pout=prz(T);
pout=[zeros(1,T/4) ones(1,T/2) zeros(1,T/4)];
end
%(psine.m)
% generating a sinusoid pulse of width T
function pout=psine(T);
pout=sin(pi*[0:T-1]/T);
end
%(binary_eye.m)
% generate and plot eyediagrams
clear;clf;
data = sign(randn(1,400)); %Generate 400 random bits
Tau=64; %Define the symbol period
dataup=upsample(data, Tau); %Generate impulse train
yrz=conv(dataup,prz(Tau)); %Return to zero polar signal
yrz=yrz(1:end-Tau+1);
ynrz=conv(dataup,pnrz(Tau)); %Non-return to zero polar
ynrz=ynrz(1:end-Tau+1);
ysine=conv(dataup,psine(Tau)); %half sinusoid polar
ysine=ysine(1:end-Tau+1);
eye1=eyediagram(yrz,Tau,Tau,Tau/2);title('RZ eye-diagram');
eye2=eyediagram(ynrz,Tau,Tau,Tau/2);title('NRZ eye-diagram');
eye3=eyediagram(ysine,Tau,Tau,Tau/2);title('Half-sine eye-diagram');
1 Comment
Jan
on 1 Jul 2013
Please follow the "? Help" link to learn how to format code in this forum. Thanks.
Accepted Answer
Pourya Alinezhad
on 1 Jul 2013
the code dose not work on my pc. because prz and psin ,... functions are not provided with the code. following code: yrz = yrz(1:end-Tau+1); removes one symbol length data from yrz's end.
More Answers (0)
See Also
Categories
Find more on Sources and Sinks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!