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

📄 ofdmcyclicalphatau.m

📁 此程序是OFDM的循环谱计算
💻 M
字号:
clear all;
%Cyclic OFDM fing alpha%
%%
%%  
%========Intial parameter=====================%
NumOfGrid_alpha=31;
NumOfGrid_tau=65;
NumOfBlock=100;
OvSampRa=1;
fs=4*10^6;
% =========== Modulation parameters ===========
Msize=16;                                   % Alphabet size
Smap=[-3+3i  -3+1i  -3-1i  -3-3i ...        % signal consellation map
      -1+3i  -1+1i  -1-1i  -1-3i ...
       1+3i   1+1i   1-1i   1-3i ...
       3+3i   3+1i   3-1i   3-3i];
% =========== OFDM parameters =========== 
fft_length=32;                              % OFDM subcarrier number

%===========Cyclostationary parameters of SOI=======================%
alpha_array=linspace(-5,5,NumOfGrid_alpha)*(1/fft_length);
delta_tau=0;
snap=fft_length*NumOfBlock;

%=========================================================================%
%                         Start simulation                                %
%=========================================================================%
TxMessage=floor(Msize*rand(1,snap));     % Total symbol
OFDM_symbol=Smap(TxMessage+1);           % Map 16-QAM
%====transform frequency to time domain=====================%
msg_mod_freq=reshape(OFDM_symbol,32,[]);
msg_mod_time=reshape(ifft(msg_mod_freq),1,[]);
%=======Pulse Shaping with rectangle pule shape=============%
msg_tx_time=rectpulse(msg_mod_time,OvSampRa);
s=msg_tx_time;
%===================================================
% Plot the cyclic auto-corellation function and
% for conjugate cyclic auto-corellation function
% for different values of tau
%===================================================
tau_val=linspace(-32,32,NumOfGrid_tau);
CAF_SOI=zeros(length(alpha_array),length(tau_val));  %cyclic auto-corellation of SOI
CCAF_SOI=zeros(length(alpha_array),length(tau_val)); %conjugate cyclic auto-corellation of SOI
MCAF_SOI=zeros(length(alpha_array),length(tau_val));  %magnitude of the cyclic auto-corellation function of SOI
for jj=1:1:length(alpha_array)
    alpha=alpha_array(jj);
    for ii=1:1:length(tau_val)
        delta_n=floor(abs(tau_val(ii))*fs);
        for n=1+delta_n:1:snap-delta_n
            CAF_SOI(jj,ii)=CAF_SOI(jj,ii)+(s(n)*...
                conj(s(n-delta_n))*exp(-j*2*pi*(alpha/fs)*n));
            CCAF_SOI(jj,ii)=CCAF_SOI(jj,ii)+(s(n)*...
                s(n-delta_n)*exp(-j*2*pi*(alpha/fs)*n));
        end
        CAF_SOI(jj,ii)=(CAF_SOI(jj,ii)/(snap-delta_n))*...
            exp(j*pi*(alpha/fs)*tau_val(ii));
        CCAF_SOI(jj,ii)=(CCAF_SOI(jj,ii)/(snap-delta_n))*...
            exp(j*pi*(alpha/fs)*tau_val(ii));
        % Magnitude of cyclic autocorrelation function
        MCAF_SOI(jj,ii)=abs(CAF_SOI(jj,ii));
        % Magnitude of cyclic conjugate autocorrelation function
        MCCAF_SOI(jj,ii)=abs(CCAF_SOI(jj,ii));
    end
end
figure(7);
[xx,yy]=meshgrid(tau_val,alpha_array);
mesh(xx,yy,MCAF_SOI);
xlabel('tau');
ylabel('alpha');
zlabel('Magnitude of  Cyclic Autocorrelation Function');
figure(8);
mesh(xx,yy,MCCAF_SOI);
xlabel('tau');
ylabel('alpha');
zlabel('Magnitude of  Conjugate Cyclic Autocorrelation Function');








% % % % % %===================================================
% % % % % % Plot the cyclic auto-corellation function and
% % % % % % for conjugate cyclic auto-corellation function
% % % % % % for different values of tau
% % % % % %===================================================
% % % % % tau_val=linspace(-0.375,0.375,NumOfGrid)*10^-6;
% % % % % CAF_SOI=zeros(length(alpha_array),length(tau_val));  %cyclic auto-corellation of SOI
% % % % % CCAF_SOI=zeros(length(alpha_array),length(tau_val)); %conjugate cyclic auto-corellation of SOI
% % % % % MCAF_SOI=zeros(length(alpha_array),length(tau_val));  %magnitude of the cyclic auto-corellation function of SOI
% % % % % % % CAF_SOI=zeros(1,length(alpha_array));  %cyclic auto-corellation of SOI
% % % % % % % CCAF_SOI=zeros(1,length(alpha_array)); %conjugate cyclic auto-corellation of SOI
% % % % % % % MCAF_SOI=zeros(1,length(alpha_array));  %magnitude of the cyclic auto-corellation function of SOI
% % % % % % % % delta_n=0;                    
% % % % % % % % ii=1;
% % % % % % % % tau_val(ii)=0;                          % tau==0
% % % % % for jj=1:1:length(alpha_array)
% % % % %     alpha=alpha_array(jj);
% % % % %        for ii=1:1:length(tau_val)
% % % % %          delta_n=floor(abs(tau_val(ii))*fs);
% % % % %         for n=1+delta_n:1:snap-delta_n
% % % % %             CAF_SOI(jj,ii)=CAF_SOI(jj,ii)+(s(n)*...
% % % % %                 conj(s(n-delta_n))*exp(-j*2*pi*(alpha/fs)*n));
% % % % %             CCAF_SOI(jj,ii)=CCAF_SOI(jj,ii)+(s(n)*...
% % % % %                 s(n-delta_n)*exp(-j*2*pi*(alpha/fs)*n));
% % % % %         end
% % % % %         CAF_SOI(jj,ii)=(CAF_SOI(jj,ii)/(snap-delta_n))*...
% % % % %             exp(j*pi*(alpha/fs)*tau_val(ii));
% % % % %         CCAF_SOI(jj,ii)=(CCAF_SOI(jj,ii)/(snap-delta_n))*...
% % % % %             exp(j*pi*(alpha/fs)*tau_val(ii));
% % % % %         % Magnitude of cyclic autocorrelation function
% % % % %         MCAF_SOI(jj,ii)=abs(CAF_SOI(jj,ii));
% % % % %         % Magnitude of cyclic conjugate autocorrelation function
% % % % %         MCCAF_SOI(jj,ii)=abs(CCAF_SOI(jj,ii));
% % % % %        end
% % % % % end
% % % % % figure(3);
% % % % % plot(alpha_array,MCAF_SOI);
% % % % % figure(4);
% % % % % plot(alpha_array,MCCAF_SOI);
% % % % % 




⌨️ 快捷键说明

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