资源简介
通信原理课程代码仅供参考,欢迎建议意见。
代码片段和文件信息
%%FileName:signal_test1.m
%%DesignedBy:
%%Date:10.22.2018
%%O_data :原始数据
%%N_sample :采样次数
function [] = signal_test1(power)
%% 生成伪随机序列(原码)
pngen = commsrc.pn(‘NumBitsOut‘2^power); % 产生 PN (伪随机噪声)信号包
data = generate(pngen); % 产生 2^power PRBS 随机序列
fs = 1e6; % 信号频率为 1MHz
Ts=1/fs; % 信号周期
N_sample = 128; % 采样次数为128个
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 生成NRZ RZ码
NRZ = []; % NRZ波形存放
RZ = []; % RZ波形存放
for i=1:length(data) % 采样的同时也是对信号进行NRZ与RZ变换
for j=1:N_sample % NRZ变换
NRZ((i-1)*N_sample+j)=data(i);
end
for j=1:(N_sample/2) % RZ变换
RZ((i-1)*N_sample+j)=data(i);
RZ((i-1)*N_sample+j+N_sample/2)=0;
end
end
figure(1) % 绘制NRZ,RZ波形图
subplot(2 2 1);plot((0:1:N_sample*length(data)-1)*Ts/N_sample RZ);grid on;axis([0 length(data)*Ts -2 2]);title(‘RZ波形‘);xlabel(‘S‘)
subplot(2 2 2);plot((0:1:N_sample*length(data)-1)*Ts/N_sample NRZ);grid on;axis([0 length(data)*Ts -2 2]);title(‘NRZ波形‘);xlabel(‘S‘)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 生成AMI码
AMI = zeros(size(data));
% number1记录原码中1的数量
number1 = 0;
% number0记录原码中0的数量
number0 = 0;
% 生成AMI码
for i=1:length(data)
if data(i)==1
number1 = number1+1;
if mod(number12)==0
AMI(i) = +1; % 原码中偶数个1为-1
end
if mod(number12)==1
AMI(i) = -1; % 原码中奇数个1为+1
end
end
if data(i)==0
number0 = number0+1; % 原码中的0保持不变
AMI(i) = 0;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 生成并绘制HDB3码
HDB = zeros(size(data));
% 给每个0000小节加V
for i= 1:length(data)
% AMI中的-1和+1保持不变
if abs(AMI(i))==1
HDB(i) = AMI(i);
end
%
end
for j= 1: (length(data)-3) %连续的四个0第三个0设为V,V用2表示
if ((AMI(j) == 0) && (AMI(j+1) == 0) && (AMI(j+2) == 0) && (AMI(j+3) == 0))
HDB(j+3) = 2;
HDB(j+2) = 0;
HDB(j+1) = 0;
HDB(j) = 0;
j = j+3;
end
end
% 每两个V极性相反
number2 = 0;
for i=1:length(data)
if HDB(i)==2
number2 = number2+1;
if mod(number22)==0
HDB(i) = +2;
end
if mod(number22)==1
HDB(i) = -2;
end
end
end
% 统计每2个V之间非零脉冲个数,若偶数,则第2个V所在小节的第1个0变为B
firstV=0;
secondV=0;
number3=0;
for i=1:length(data)
% 找到第一个V
if abs(HDB(i)) == 2
firstV = i;
相关资源
- PRBS信号进行QPSK调制;画出星座图;加
- 双闭环不可逆直流调速系统课程设计
- 脉冲编码调制(PCM)实现
- 通信原理课程设计 扩频通信
- 温度控制系统的设计-自动控制原理课
- HDB3码的matlab实现
- EDA课程设计之汽车尾灯设计
- 通信原理基于matlab的计算机仿真_源代
- 自动控制系统校正课程设计
- MATLAB课程设计(cantor三分集)
- MATLAB写的成绩管理系统
- MATLAB课程设计——数字带通FIR滤波器
- 通信原理中16QAM信号 MATLAB程序
- matlab设计滤波器课程设计程序
-
基于MatlabSimuli
nk数字基带传输系统仿 - 基于Matlab的QAM调制系统仿真课程设计
- 自动控制原理课程设计--用MATLAB进行控
- 数字信号处理课程设计
- 数字逻辑出租车课程设计
- MATLAB 课程设计
- 通信原理课程设计报告ASK FSK PSK Matl
- 通信系统课群综合课程设计
- UML 课程设计 新生报到注册系统
- DSP课程设计——卷积编译码的DSP实现
- ACCESS 课程设计
- 基于MATLAB的语音信号处理课程设计
- 模电课程设计小型音频功放
- 通信原理pcm编码及解码
- 通信原理8dpsk调制及其误码率曲线
- 通信原理仿真实验 matlab
评论
共有 条评论