OTFS系统建模、通信性能分析、信道估计、模糊函数【附MATLAB代码】

文献来源:​微信公众号:EW Frontier

OTFS简介

OTFS信道估计

% Clear command window, workspace variables, and close all figures
clc; 
clear all; 
close all;
​
% Define Eb values in dB
EbdB = -10:2:10;
​
% Convert Eb values from dB to linear scale
Eb = 10.^(EbdB/10);
​
% Define Noise Power
No = 1;
​
% Calculate Signal-to-Noise Ratio (SNR) in linear scale
SNR = 2*Eb/No;
​
% Convert SNR to dB scale
SNRdB = 10*log10(SNR);
​
% Define matrix dimensions and parameters
M = 32; 
N = 16;
Ptx = eye(M); 
Prx = eye(M);
nTaps = 5;
DelayTaps = [0 1 2 3 4];
DopplerTaps = [0 1 2 3 4];
Ncp = max(DelayTaps);
​
% Initialize arrays to store Bit Error Rate (BER) for different methods
BER_MMSE = zeros(length(Eb),1);
BER_ZF = zeros(length(Eb),1);
​
% Number of iterations for Monte Carlo simulation
ITER = 10;
​
% Precompute matrices for transformation
F_M = 1/sqrt(M)*dftmtx(M);
F_N = 1/sqrt(N)*dftmtx(N);
​
% Main loop for Monte Carlo simulation
for ite = 1:ITER
    ite
    
    % Generate random bits for transmission
    XddBits = randi([0,1],M,N);
    
    % Generate random channel taps
    h = sqrt(1/2)*(randn(1,nTaps)+ 1j*randn(1,nTaps));
    
    % Construct effective channel matrix
    Hmat = zeros(M*N,M*N);
    omega = exp(1j*2*pi/(M*N));
    for tx = 1:nTaps
        Hmat = Hmat + h(tx)*circshift(eye(M*N),DelayTaps(tx))*...
            (diag(omega.^((0:M*N-1)*DopplerTaps(tx))));
    end
    Heff = kron(F_N,Prx)*Hmat*kron(F_N',Ptx);
    
    % Generate Complex Noise
    ChNoise = sqrt(No/2)*(randn(1,M*N) + 1j*randn(1,M*N));
    
    % Loop over different Eb/N0 values
    for ix = 1:length(Eb)
        % Generate modulated symbols
        X_DD = sqrt(Eb(ix))*(2*XddBits-1); 
        X_TF = F_M*X_DD*F_N';
        S_mat = Ptx*F_M'*X_TF;        
        TxSamples = reshape(S_mat,M*N,1).';
        TxSamplesCP = [TxSamples(M*N-Ncp+1:M*N) TxSamples];
        
        % Channel filtering
        RxsamplesCP = 0;
        for tx = 1:nTaps
            Doppler = exp(1j*2*pi/M*(-Ncp:M*N-1)*DopplerTaps(tx)/N);
            RxsamplesCP = RxsamplesCP + h(tx)*circshift(TxSamplesCP.*Doppler,[1, DelayTaps(tx)]);
        end
        
        % Remove cyclic prefix
        Rxsamples = RxsamplesCP(Ncp+1:M*N+Ncp) + ChNoise;
        R_mat = reshape(Rxsamples.',M, N) ;
        Y_TF = F_M*Prx*R_mat;
        Y_DD = F_M'*Y_TF*F_N;
        y_DD = reshape(Y_DD, M*N, 1) ;
        
        % MMSE Equalization
        xhatMMSE = inv(Heff'*Heff + eye(M*N)/Eb(ix))*Heff'*y_DD;
        DecodedBits = (real(xhatMMSE) >= 0);
        BER_MMSE(ix) = BER_MMSE(ix) + sum(DecodedBits ~= reshape(XddBits,M*N,1));
        
        % Zero Forcing (ZF) Equalization
        xhatZF = pinv(Heff)*y_DD;
        DecodedBits = (real(xhatZF) >= 0);
        BER_ZF(ix) = BER_ZF(ix) + sum(DecodedBits ~= reshape(XddBits,M*N,1));
    end
end
​
% Average BER over iterations and symbols
BER_MMSE = BER_MMSE/M/N/ITER;
BER_ZF = BER_ZF/M/N/ITER;
​
% Plot BER versus SNR
semilogy(EbdB,BER_MMSE,'b-s','linewidth',3.0,'MarkerFaceColor','b','MarkerSize',9.0);
hold on; 
grid on; 
semilogy(EbdB,BER_ZF,'r-o','linewidth',3.0,'MarkerFaceColor','r','MarkerSize',9.0);
axis tight;
legend('MMSE','ZF');
title('OTFS BER v/s SNR');
xlabel('SNR(dB)'); 
ylabel('BER');
​

OTFS系统建模

% Clear command window, workspace variables, and close all figures
clc; 
clear all; 
close all;
​
% Define Eb values in dB
EbdB = -10:2:10;
​
% Convert Eb values from dB to linear scale
Eb = 10.^(EbdB/10);
​
% Define Noise Power
No = 1;
​
% Calculate Signal-to-Noise Ratio (SNR) in linear scale
SNR = 2*Eb/No;
​
% Convert SNR to dB scale
SNRdB = 10*log10(SNR);
​
% Define matrix dimensions and parameters
M = 32; 
N = 16;
Ptx = eye(M); 
Prx = eye(M);
nTaps = 5;
DelayTaps = [0 1 2 3 4];
DopplerTaps = [0 1 2 3 4];
Ncp = max(DelayTaps);
​
% Initialize arrays to store Bit Error Rate (BER) for different methods
BER_MMSE = zeros(length(Eb),1);
BER_ZF = zeros(length(Eb),1);
​
% Number of iterations for Monte Carlo simulation
ITER = 10;
​
% Precompute matrices for transformation
F_M = 1/sqrt(M)*dftmtx(M);
F_N = 1/sqrt(N)*dftmtx(N);
​
% Main loop for Monte Carlo simulation
for ite = 1:ITER
    ite
    
    % Generate random bits for transmission
    XddBits = randi([0,1],M,N);
    
    % Generate random channel taps
    h = sqrt(1/2)*(randn(1,nTaps)+ 1j*randn(1,nTaps));
    
    % Construct effective channel matrix
    Hmat = zeros(M*N,M*N);
    omega = exp(1j*2*pi/(M*N));
    for tx = 1:nTaps
        Hmat = Hmat + h(tx)*circshift(eye(M*N),DelayTaps(tx))*...
            (diag(omega.^((0:M*N-1)*DopplerTaps(tx))));
    end
    Heff = kron(F_N,Prx)*Hmat*kron(F_N',Ptx);
    
    % Generate Complex Noise
    ChNoise = sqrt(No/2)*(randn(1,M*N) + 1j*randn(1,M*N));
    
    % Loop over different Eb/N0 values
    for ix = 1:length(Eb)
        % Generate modulated symbols
        X_DD = sqrt(Eb(ix))*(2*XddBits-1); 
        X_TF = F_M*X_DD*F_N';
        S_mat = Ptx*F_M'*X_TF;        
        TxSamples = reshape(S_mat,M*N,1).';
        TxSamplesCP = [TxSamples(M*N-Ncp+1:M*N) TxSamples];
        
        % Channel filtering
        RxsamplesCP = 0;
        for tx = 1:nTaps
            Doppler = exp(1j*2*pi/M*(-Ncp:M*N-1)*DopplerTaps(tx)/N);
            RxsamplesCP = RxsamplesCP + h(tx)*circshift(TxSamplesCP.*Doppler,[1, DelayTaps(tx)]);
        end
        
        % Remove cyclic prefix
        Rxsamples = RxsamplesCP(Ncp+1:M*N+Ncp) + ChNoise;
        R_mat = reshape(Rxsamples.',M, N) ;
        Y_TF = F_M*Prx*R_mat;
        Y_DD = F_M'*Y_TF*F_N;
        y_DD = reshape(Y_DD, M*N, 1) ;
        
        % MMSE Equalization
        xhatMMSE = inv(Heff'*Heff + eye(M*N)/Eb(ix))*Heff'*y_DD;
        DecodedBits = (real(xhatMMSE) >= 0);
        BER_MMSE(ix) = BER_MMSE(ix) + sum(DecodedBits ~= reshape(XddBits,M*N,1));
        
        % Zero Forcing (ZF) Equalization
        xhatZF = pinv(Heff)*y_DD;
        DecodedBits = (real(xhatZF) >= 0);
        BER_ZF(ix) = BER_ZF(ix) + sum(DecodedBits ~= reshape(XddBits,M*N,1));
    end
end
​
% Average BER over iterations and symbols
BER_MMSE = BER_MMSE/M/N/ITER;
BER_ZF = BER_ZF/M/N/ITER;
​
% Plot BER versus SNR
semilogy(EbdB,BER_MMSE,'b-s','linewidth',3.0,'MarkerFaceColor','b','MarkerSize',9.0);
hold on; 
grid on; 
semilogy(EbdB,BER_ZF,'r-o','linewidth',3.0,'MarkerFaceColor','r','MarkerSize',9.0);
axis tight;
legend('MMSE','ZF');
title('OTFS BER v/s SNR');
xlabel('SNR(dB)'); 
ylabel('BER');
​


OTFS系统建模
clc; clear all; close all;
% SIGNAL MODEL OF OTFS
M = 32; N = 32;                 %M-> no. of subcarriers/delay bins ; N-> no. of symbols/doppler bins
F_M = 1/sqrt(M)*dftmtx(M);      %disrete fourier transform matrix (normalised)   
F_N = 1/sqrt(N)*dftmtx(N);      %forms the grid
Ptx = eye(M);
delta_f = 15e3;                 %subcarrier BW
T = 1/delta_f;                  %OFDM symbol Duration
​
                   
X_DD = zeros(M,N);              %Delay Doppler Grid
X_DD(3, 3) = 1;                 %impulse in DD Domain
X_TF = F_M*X_DD*F_N';            
S = Ptx*F_M'
*X_TF;
s = reshape(S,M*N,1);
​
​
​
​
% figure()
subplot(4,2,[1,2,3,4])
bar3(X_DD);
axis tight;
xlabel('Doppler'); 
ylabel('Delay');
title('Basis function in DD-domain');
​
% figure()
subplot(4,2,5)
surf(real(X_TF));
axis tight;
xlabel('Time'); 
ylabel('Subcarrier');
title('Basis function in TF-domain (Real)');
​
% figure()
subplot(4,2,6)
surf(imag(X_TF));
axis tight;
xlabel('Time'); 
ylabel('Subcarrier');
title('Basis function in TF-domain (Imag)');
​
% figure()
subplot(4,2,7)
plot((0:length(s)-1)*T/M,real(s));
axis tight;
ylim([-0.5 0.5]);
xlabel('Time');
title('Basis function in time-domain (Real)');
​
% figure()
subplot(4,2,8)
plot((0:length(s)-1)*T/M,imag(s));
axis tight;
ylim([-0.5 0.5]);
xlabel('Time');
title('Basis function in time-domain (Imag)');
​

OTFS系统性能部分代码

% Clear command window, workspace variables, and close all figures
clc; 
clear all; 
close all;
​
% Define Eb values in dB
EbdB = 2;
​
% Convert Eb values from dB to linear scale
Eb = 10.^(EbdB/10);
​
% Define Noise Power
No = 1;
​
% Calculate Signal-to-Noise Ratio (SNR) in linear scale
SNR = 2*Eb/No;
​
% Convert SNR to dB scale
SNRdB = 10*log10(SNR);
​
% Define matrix dimensions and parameters
M = 32; 
N = 16;
Ptx = eye(M); 
Prx = eye(M);
nTaps = 5;
DelayTaps = [5 1 0 3 4];
DopplerTaps = [0 3 2 3 4];
Ncp = max(DelayTaps);
​
​
% Precompute matrices for transformation
F_M = 1/sqrt(M)*dftmtx(M);
F_N = 1/sqrt(N)*dftmtx(N);
​
% Generate random bits for transmission
XddBits = randi([0,1],M,N);
​
% Generate random channel taps
h = sqrt(1/2)*(randn(1,nTaps)+ 1j*randn(1,nTaps));
​
% Construct effective channel matrix
Hmat = zeros(M*N,M*N);
omega = exp(1j*2*pi/(M*N));
for tx = 1:nTaps
    Hmat = Hmat + h(tx)*circshift(eye(M*N),DelayTaps(tx))*...
        (diag(omega.^((0:M*N-1)*DopplerTaps(tx))));
end
Heff = kron(F_N,Prx)*Hmat*kron(F_N',Ptx);
    
% Generate Complex Noise
ChNoise = sqrt(No/2)*(randn(1,M*N) + 1j*randn(1,M*N));
    
% Generate modulated symbols
X_DD = sqrt(Eb)*(2*XddBits-1); 
X_TF = F_M*X_DD*F_N';
S_mat = Ptx*F_M'*X_TF;        
TxSamples = reshape(S_mat,M*N,1).';
TxSamplesCP = [TxSamples(M*N-Ncp+1:M*N) TxSamples];
​
% Channel filtering
RxsamplesCP = 0;
for tx = 1:nTaps
    Doppler = exp(1j*2*pi/M*(-Ncp:M*N-1)*DopplerTaps(tx)/N);
    RxsamplesCP = RxsamplesCP + h(tx)*circshift(TxSamplesCP.*Doppler,[1, DelayTaps(tx)]);
end
​
% Remove cyclic prefix
Rxsamples = RxsamplesCP(Ncp+1:M*N+Ncp) + ChNoise;
R_mat = reshape(Rxsamples.',M, N) ;
Y_TF = F_M*Prx*R_mat;
Y_DD = F_M'*Y_TF*F_N;
y_DD = reshape(Y_DD, M*N, 1) ;
​
% MMSE Equalization
xhatMMSE = inv(Heff'*Heff + eye(M*N)/Eb)*Heff'*y_DD;
DecodedBits_MMSE = (real(xhatMMSE) >= 0);
DecodedBits_MMSE_reshaped = reshape(DecodedBits_MMSE,M,N);
BER_MMSE_Map = (DecodedBits_MMSE_reshaped ~= XddBits);
BER_MMSE = sum(DecodedBits_MMSE ~= reshape(XddBits,M*N,1));
​

OTFS模糊函数部分代码

% Clear command window, workspace variables, and close all figures
clc; 
clear all; 
close all;
​
% Define Eb values in dB
EbdB = 3;
​
% Convert Eb values from dB to linear scale
Eb = 10.^(EbdB/10);
​
% Define Noise Power
No = 1;

Size,Data Set,Comparisons,Moves,Time\n"); for (i = 0; i < num_sizes; i++) { n = sizes[i]; for (j = 1; j <= num_data; j++) { // 读取数据文件OTFS信道估计的导频开销主要由两部分组成:导频符号的数量和导频 char filename[50]; sprintf(filename, "data_%d_%d.in", n, j); FILE *f = fopen符号的分布方式。 在OTFS系统中,每个时频格点需要估计一个复数值,因此(filename, "r"); for (k = 0; k < n; k++) fscanf(f, "%d", &arr[k需要至少一个导频符号来进行估计。导频符号的数量可以根据信道条件和系统性能]); fclose(f); // 排序 count_cmp = 0; count_move = 0; begin = clock需求来确定。一般来说,导频符号越多,信道估计的准确性就越高,(); heapSort(arr, n); end = clock(); time_spent = (double)(end - begin) / CLOCKS但导频开销也越大。 导频符号的分布方式可以通过在时频域中选择一定的规_PER_SEC; // 写入结果 fprintf(fp, "%d,%d,%d,%d,%f\n", n, j,律来实现。例如,在时域中可以采用等间隔分布或者根据Zadoff-Chu序列 count_cmp, count_move, time_spent); } } fclose(fp); // 测试归并排序 printf("Merge产生导频符号,而在频域中可以采用等间隔或者随机分布的方式。不同 Sort:\n"); fp = fopen("merge_sort.csv", "w"); fprintf(fp, "Size,Data Set,Comparisons,M的分布方式会影响到导频开销和信道估计的准确性。 具体的导频开销oves,Time\n"); for (i = 0; i < num_sizes; i++) { n = sizes[i]; for需要根据具体的系统参数和信道条件来进行计算。在MATLAB中,可以使用OTFS工具箱 (j = 1; j <= num_data; j++) { // 读取数据文件 char filename[50]; 来进行OTFS系统建模和仿真,从而得到导频开销的估计值。同时,也可以 sprintf(filename, "data_%d_%d.in", n, j); FILE *f = fopen(filename, "r"); for (通过模拟得到不同导频符号数量和分布方式下的信道估计性能,从而进行系统设计和优化。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值