MATLAB simulates and draws four basic baseband signals - bipolar non-return to zero code (DNRZ), bipolar return to zero code (DRZ), unipolar non-return to zero code (SNRZ), unipolar return to zero code (SRZ) time domain waveform and its power spectrum
Table of contents
1. Bipolar non-return-to-zero code
2. Bipolar return-to-zero code
3. Unipolar non-return-to-zero code
4. Unipolar return-to-zero code
5. Power spectrum of four basic waveforms
6. MATLAB draws four basic waveforms and their power spectra
Tip: The following is the text of this article. It is not easy to write an article. I hope it can help you. Please attach a link for reprinting.
1. Bipolar non-return-to-zero code
-
No DC
-
1—high level+1; 0—negative level-1
2. Bipolar return-to-zero code
-
No DC
-
The basic rules are the same as the bipolar non-return-to-zero code, but there are 50% zero levels in a signal code cycle
3. Unipolar non-return-to-zero code
-
Unipolar: 1-high level; 0-0 level, the level remains unchanged during the duration of the symbol
-
Not return to zero: NRZ (nor-return to zero)
-
There is DC and a fixed 0 level, mostly used for terminal equipment or short-distance transmission (within or between circuit boards)
4. Unipolar return-to-zero code
-
Return to zero: When RZ (return to zero) sends a "1" code, the high level only lasts for a period of time during the code element (usually the duty cycle is 50%), and is mostly used for short-range waveform transformation;
-
There is direct current;
-
Bit timing can be extracted directly;
-
Rules: 1-high level; 0-0 level (same as unipolar non-return-to-zero code), but in a timing signal, there is a return-to-zero phenomenon, that is, for example, binary 1-high point is flat 1, but there is Return to zero, the high level cannot occupy the entire timing signal, but there will be a 50% duty cycle of 0 level.
5. Power spectrum of four basic waveforms
6. MATLAB draws four basic waveforms and their power spectra
7. MATLAB code
clc;
clear all;
close all;
N=10000; % 码元个数
fc=1e9; % 载波信号频率
Rb=1e6; % 码速率
sps=16; % 每个码元的采样点数
fs=Rb*sps; % 采样频率
n=N*sps; % 总的采样点数
ts=1/fs; % 最小采样间隔
Tb=ts*sps; % 码元周期
t1=(1:N)*Tb; % 码元持续时间
t2=(1:n)*ts; % 总的持续时间
%% 产生双极性不归零基带信号
x=randi([0 1],1,N)*2-1; % 产生双极性序列 1 -1
figure(1);
subplot(211);
stem(t1(1:20),x(1:20));grid on;
ylim([-1.2 1.2]);
title('双极性不归零基带信号');
x1=repmat(x,sps,1); %将x复制sps行
xt=reshape(x1,1,n); %将x1按列拼接成行向量
subplot(212);
plot(t2(1:20*sps),xt(1:20*sps));grid on;
ylim([-1.2 1.2]);
title('双极性不归零基带信号时域波形');
figure(2);
[p,f]=pwelch(xt,500,300,500,fs,'centered','power'); %500,300,500分别为计算样本点数,重叠点数,DFT点数
plot(f,10*log10(p));
xlabel('Frequency (Hz)');ylabel('Magnitude (dB)');title('双极性不归零基带信号功率谱');
%% 产生双极性归零基带信号
x=randi([0 1],1,N)*2-1;
figure(3);
subplot(211);
stem(t1(1:20),x(1:20));grid on;
ylim([-1.2 1.2]);
title('双极性归零基带信号');
x1=repmat(x,sps/2,1);
x2=[x1;zeros(sps/2,N)];
xt=reshape(x2,1,n);
subplot(212);
plot(t2(1:20*sps),xt(1:20*sps));grid on;
ylim([-1.2 1.2]);
title('双极性归零基带信号时域波形');
figure(4);
[p,f]=pwelch(xt,500,300,500,fs,'centered','power'); %500,300,500分别为计算样本点数,重叠点数,DFT点数
plot(f,10*log10(p));
xlabel('Frequency (Hz)');ylabel('Magnitude (dB)');title('双极性归零基带信号功率谱');
%% 产生单极性不归零基带信号
x=randi([0 1],1,N); % 产生双极性序列 1 0
figure(5);
subplot(211);
stem(t1(1:20),x(1:20));grid on;
ylim([-0.2 1.2]);
title('单极性不归零基带信号');
x1=repmat(x,sps,1);
xt=reshape(x1,1,n);
subplot(212);
plot(t2(1:20*sps),xt(1:20*sps));grid on;
ylim([-0.2 1.2]);
title('单极性不归零基带信号时域波形');
figure(6);
[p,f]=pwelch(xt,500,300,500,fs,'centered','power'); %500,300,500分别为计算样本点数,重叠点数,DFT点数
plot(f,10*log10(p));
xlabel('Frequency (Hz)');ylabel('Magnitude (dB)');title('单极性不归零基带信号功率谱');
%% 产生单极性归零基带信号
x=randi([0 1],1,N); % 产生双极性序列 1 0
figure(7);
subplot(211);
stem(t1(1:20),x(1:20));grid on;
ylim([-0.2 1.2]);
title('单极性归零基带信号');
x1=repmat(x,sps/2,1);
x2=[x1;zeros(sps/2,N)];
xt=reshape(x2,1,n);
subplot(212);
plot(t2(1:20*sps),xt(1:20*sps));grid on;
ylim([-0.2 1.2]);
title('单极性归零基带信号时域波形');
figure(8);
[p,f]=pwelch(xt,500,300,500,fs,'centered','power'); %500,300,500分别为计算样本点数,重叠点数,DFT点数
plot(f,10*log10(p));
xlabel('Frequency (Hz)');ylabel('Magnitude (dB)');title('单极性归零基带信号功率谱');
Summarize
The above is all I want to talk about today. I hope it will be helpful to everyone.