⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 receiver_p1of2_md1of2.m

📁 数字音频信号的调制与解调的源码程序.可保证声音信号怒失真输出
💻 M
字号:
%this is the first part of a receiver of total 2 parts
%the main task is from null detector to partitioning
%after that, the signal should be windowed
%There are two methods to do the job and this is the first,traditional one

%frame_1中除了null外的symbol数,存在n_of_s里
n_of_s=floor(length(frame_1)/Ts)-1;
frame=frame_1;                               %以后用这行,取代下面那行
%frame=offset_adder(frame_1);                  %加频偏,以后就不用了,因为将要接收实际信号
%经检验,加了频偏后,null detector和frame detector都工作良好
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                    null detector,结果放在coarse_frame_start里                      %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%从收到的第一个数据开始,找出第一个不为0的点,也就是找出一帧开始的粗略位置
%理论上null symbol的数据值都是0,所以PRS到来以后,应该有比较明显的阶跃出现
%0.005这个数是经过试验取的,可以根据情况再改进
coarse_frame_start=1;
while(abs(frame(coarse_frame_start))<0.005)
    coarse_frame_start=coarse_frame_start+1;
end
disp('The coarse start of this frame is:');
disp(coarse_frame_start);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                    frame detector,结果放在fine_frame_start里                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%在null_detector检测出一帧信号大致的起始位置以后,
%frame_detector检测出精确的起始位置,方法是借用receiver中存储的PRS,
%和接收到的信号做cross-correlation,由于已经检测出大致位置了,所以
%需要做互相关的点不必很多,注意,要包括左移。本例中为左右各检测8个点。

%取PRS的前delta+1~delta+17共16个点,存在C里
%注意,因为CP可能被多径所影响,所以取中间部分的点比较可靠
C=PRS(1,delta+1:delta+17);
n=1:16;

%定义互相关函数R(m)
R=[];
for m=1:17                                     %没有办法,本应是[-8,+8],只能写成[1,17]
    R(m)=sum(C(n)*(frame(n+m+coarse_frame_start-1-9+delta))'); %用求和函数sum省去一次循环,增加执行效率
    m=m+1;
end

%PRS的起始位置放在n_sync1,该点的abs峰值放在R_max
%fine_frame_start中存储的是最终得到的PRS起始点位置(本例中为2657=n_sync)
[R_max,n_sync1]=max(abs(R));
fine_frame_start=n_sync1-9+coarse_frame_start;
disp('The fine start of this frame is:');
disp(fine_frame_start);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                    freq corrector,结果放在freq_correct里                     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%调用offset_remover函数,把oscillator产生的offset去掉以后,再进行后续处理
%注意,由于计算精度的原因,纠偏后还有一点点差异,但完全可以忽略,大约是1:80量级
freq_correct=frame;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                    partitioning,结果放在data_partition里                     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%根据上面得到的fine_frame_start,按照标准长度Tu对信号进行分块,并把除了null和PRS
%外的数据(data symbols)存储在n_data*Ts的矩阵data_partition里
%...的意思是未完待续...
data_partition=[];
for i_data=1:n_of_s-1
    data_partition=[data_partition;freq_correct((fine_frame_start+Ts*i_data):(fine_frame_start...
            +Ts*(i_data+1)-1))];
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -