www.gusucode.com > MATLAB,PSK_QAM误码率源码程序 > MATLAB,PSK_QAM误码率源码程序/subspace_channel_identification_4_STBC/one_shot.m

    %HELP one_shot
%
%Illustrate how to use the channel estimation script. This code generate a
%MIMO communication with Space time encoding. Then the channel is estimated
%through a subspace approach using the knowledge of the Space time code
%structure. Note that the method is not able to estimate correctly the
%channel for non-identifiable STBCs( Alamouti, Spatial Multiplexing,
%>=1-rate STBCs). See publication [1] for details.
%
%Reference:
%
%[1] Ammar, N.; Ding, Z. "Blind Channel Identifiability for Generic
%Linear Space-Time Block Codes" IEEE Transactions on Signal Processing
%Volume 55, Issue 1, Jan. 2007 Page(s):202 - 217
%
%Programmed by V. Choqueuse (vincent.choqueuse@gmail.com)

%Simulation parameters

N=512;                  %Number of symbols to be transmitted 
code_name='OSTBC3';     %Space time code (see file space_time_coding to obtain the list of supported STBC)
rate='3/4';             %Space time code (see file space_time_coding to obtain the list of supported STBC)
num_code=1;             %Space time code (see file space_time_coding to obtain the list of supported STBC)
modulation='PSK';       %supported modulation PSK, QAM,
state_nb=4;             %modulation with 4 states (4-PSK -> QPSK)
nb_receivers=4;         %Number of 4 receivers
snr=5;                  %Signal to noise ratio (dB)

close all;
fprintf('\n+-----------------------------------+\n');
fprintf('|   Simulate a MIMO communication   |\n');
fprintf('+-----------------------------------+\n\n');

%% extract space time block coding information
code_rate=str2num(rate);
[nb_emitters,code_length]=size(space_time_coding(0,code_name,rate,num_code,1));
Nb_symbole_code=code_length*str2num(rate);

%% Generate a symbol sequence randomly. The symbols belong to the set of
%%integer: [0 state_nb-1]
fprintf('- Generate %d random symbols: ',N);
symbols=randint(1,code_rate*N,state_nb);
fprintf('\t\t\tOK\n');
  
%% Modulate the symbols
fprintf('- Apply %d-%s constellation: ',state_nb,modulation);    
switch modulation
    case 'PSK'
        modulator=modem.pskmod(state_nb);
    case 'QAM'
        modulator=modem.qammod(state_nb);
end       
modulated_symbols=modulate(modulator,symbols);
fprintf('\t\t\tOK\n');

%% perform space time encoding
fprintf('- Perform %s-%s STBC encoding:',rate,code_name);
[STBC_blocs]=space_time_coding(modulated_symbols,code_name,rate,num_code);
fprintf('\t\tOK\n');

%% Create a random channel matrix
fprintf('- Generate a %d * %d Random Channel: ',nb_receivers,nb_emitters);
channel_matrix=sqrt(0.5)*(randn(nb_receivers,nb_emitters)+i*randn(nb_receivers,nb_emitters));
received_signal=channel_matrix*STBC_blocs;
fprintf('\t\tOK\n');

%% Apply AWGN noise
fprintf('- Apply %d dB additive noise: ',snr);
noise_variance=1/(10^(snr/10));
bruit=(sqrt(noise_variance/2))*(randn(nb_receivers,size(STBC_blocs,2))+...
                                i*randn(nb_receivers,size(STBC_blocs,2)));                          
received_signal=received_signal+bruit;
fprintf('\t\t\tOK (noise variance=%f)\n',noise_variance);

%% Perform Channel estimation
fprintf('- Perform Subspace Channel Estimation: ');
estimated_channel_matrix=subspace_channel_estimation_STBC(received_signal,code_name,rate,num_code);
fprintf('\tOK\n');
fprintf('- Compute pinv(H_est)*H:\n');

pinv_H_est_H=pinv(estimated_channel_matrix)*channel_matrix   %close to a diagonal matrix for correct estimation
fprintf(' (Result must be closed to a diagonal matrix with equal diagonal element)\n')