# Channel Estimation

**URL:** <https://vccsforum.nt.tuwien.ac.at/t/channel-estimation/328>\
**Category:** Vienna 5G Link Level Simulator\
**Created:** [February 22, 2024, 2:03am UTC](https://vccsforum.nt.tuwien.ac.at/t/channel-estimation/328 "2024-02-22T02:03:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stren](https://vccsforum.nt.tuwien.ac.at/letter_avatar_proxy/v4/letter/s/e79b87/32.png) [@stren](https://vccsforum.nt.tuwien.ac.at/u/stren)\
**Post date:** [February 22, 2024, 2:03am UTC](https://vccsforum.nt.tuwien.ac.at/t/channel-estimation/328/1 "2024-02-22T02:03:55Z")

</div>

![image](https://vccsforum.nt.tuwien.ac.at/uploads/default/original/1X/a1002fc40d46f94ff23b86de1fb3e1682811b582.png)  
Hello, I would like to use ‘PilotSymbolAidedChannelEstimation’ for OTFS modulation based channel estimation, but I am not very familiar with this class. Do you have any suggestions? The following code is something I have tried to write myself.  
% 二进制数据  
BinaryDataStream\_OFDM = randi([0 1],K,1);  
%编码  
CodedBits = coderIn.encode(BinaryDataStream\_OFDM );  
% 传输的数据符号（将二进制数据映射到QAM）  
x\_OFDM = QAM.Bit2Symbol(CodedBits);  
x\_OFDM = reshape( x\_OFDM ,OFDM.Nr.Subcarriers,OFDM.Nr.MCSymbols );  
% 时域中的传输信号（这行代码执行OFDM调制过程。它将调制后的数据x\_OFDM转换为时域信号s\_OFDM，这个时域信号包含了要通过无线信道发送的OFDM符号。）  
% 生成导频符号并插入到OFDM符号中  
% 此处我们假设 InsertPilots 是一个自定义函数，用于根据导频模式生成导频符号并插入  
x\_OFDM\_withPilots = ChannelEstimation.PilotSymbolAidedChannelEstimation.InsertPilots(x\_OFDM, channelEstimationObj.PilotMatrix);

```
% OTFS调制   
S_otfs = Modulation.ISFFT(x_OFDM);

s_OFDM = OFDM.Modulation(S_otfs);

% 通道卷积（模拟了多径效应等信道特性。r_OFDM_noNoise是通过信道传输后的接收信号，此时还没有考虑噪声的影响。）
r_OFDM_noNoise = ChannelModel.Convolution(s_OFDM);

% 单抽头均衡器的信道（仅代表近似值，因为没有考虑脉冲前）（ChannelModel.GetTransferFunction方法获取信道在特定频率点的响应，用于后续的信号均衡处理。这些频率点对应于OFDM系统中使用的子载波频率。）
h_OFDM = ChannelModel.GetTransferFunction(OFDM.GetTimeIndexMidPos,OFDM.Implementation.FFTSize,(1:OFDM.Nr.Subcarriers)+OFDM.Implementation.IntermediateFrequency);   

% 添加噪声
SNR_OFDM_dB = Simulation_SNR_OFDM_dB(i_SNR);%该数组预先定义了要模拟的不同SNR水平。

Pn_time = 1/mean(mean(OFDM.GetSymbolNoisePower(1)))*10^(-SNR_OFDM_dB/10);
%算时域中的噪声功率Pn_time。这里使用OFDM.GetSymbolNoisePower(1)获取一个OFDM符号的平均噪声功率，然后通过SNR计算出对应的噪声功率水平。
noise = sqrt(Pn_time/2)*(randn(length(s_OFDM),1)+1j*randn(length(s_OFDM),1));
%生成复高斯噪声，其实部和虚部均为高斯分布，噪声的功率由之前计算的Pn_time确定。因为复信号的功率是实部和虚部功率的和，所以每部分乘以sqrt(Pn_time/2)。
    
r_OFDM = r_OFDM_noNoise + noise(1:N_OFDM);%将噪声加到无噪声信号r_OFDM_noNoise上，得到接收信号r_OFDM。

% 解调OFDM信号
y_OFDM = OFDM.Demodulation(r_OFDM);%将接收到的信号r_OFDM进行OFDM解调，恢复出调制前的数据符号y_OFDM

% 导频符号的提取（这需要根据你的导频设计来实现）

```

[PilotsExtracted, PilotPositions] = ExtractPilots(y\_OFDM, channelEstimationObj.PilotMatrix);  
% 使用导频符号进行信道估计  
LSChannelEstimatesAtPilotPosition = ChannelEstimationMethod(PilotsExtracted, PilotPositions);  
%InterpolatedChannel = channelEstimationObj.ChannelInterpolation(LSChannelEstimatesAtPilotPosition, …);

```
% 单抽头均衡器

```

% y\_OneTapEqualizer\_OFDM = Y\_dd./h\_OFDM;%使用单抽头均衡器处理解调后的信号y\_OFDM，以补偿信道造成的失真。均衡器使用之前计算的信道传输函数h\_OFDM。  
y\_OneTapEqualizer\_OFDM= Modulation.OTFS\_MMSE\_Equalizer( y\_OFDM,h\_OFDM,Pn\_time );%mmse  
% otfs解调  
Y\_dd = Modulation.SFFT(y\_OneTapEqualizer\_OFDM );

```
% 使用接收符号和噪声功率计算LLR值
LLR_OFDM = -QAM.LLR_AWGN(Y_dd(:), Pn_time);

DecodedBits = coderIn.decode(LLR_OFDM );%对检测到的比特流进行解码，恢复出原始的二进制数据流DecodedBits

% 累加当前SNR下的错误数
error_counts(i_SNR, coderIndex) = error_counts(i_SNR, coderIndex)+sum(BinaryDataStream_OFDM ~= DecodedBits);

```

---

<div class="post-metadata">

**Author:** ![Bashar](https://vccsforum.nt.tuwien.ac.at/user_avatar/vccsforum.nt.tuwien.ac.at/bashar/32/70_2.png) [@Bashar](https://vccsforum.nt.tuwien.ac.at/u/Bashar)\
**Post date:** [February 26, 2024, 8:43am UTC](https://vccsforum.nt.tuwien.ac.at/t/channel-estimation/328/2 "2024-02-26T08:43:54Z")

</div>

Hello,

We can only help if you have a specific question regarding some functionality in the simulator.

Best,  
Bashar
