function [code_name_detected,rate_detected,num_detected,index_detected]=...
CP_Classifier(received_signal,code_name_list,rate_list,num_code_list,display)
%HELP Optimal_Classifier
%
%Perform the classification of several STBC from the received signal with
%the OptimalClassifier
%
%Input: - received_signal
% - code_name_list
% - rate_list
% - num_code_list
% - 1: display LF/ 0: No display
%
%Output: - code_name_detected (code name of the code_name_list)
% - rate_detected
% - num_detected
% - index_detected (index number of the code in the code list)
%
%reference: [1] V. Choqueuse, M. Marazin, L. Collin, K.C. Yao, K and G. Burel
%"Blind Recognition of Linear SpaceTime Block Codes: A Likelihood-Based
%Approach" IEEE Transactions on Signal Processing, Vol 58 (3), p 1290-1299,
%2010
Nb_possible_code=length(num_code_list);
for code_index=1:Nb_possible_code
code_name_temp=code_name_list{code_index};
rate_temp=rate_list{code_index};
num_code_temp=num_code_list(code_index);
%extract code parameter (nt,l,n)
[nt,l]=size(space_time_coding(0,code_name_temp,rate_temp,num_code_temp,1));
n=l*str2num(rate_temp);
LF(code_index)=compute_LF_CP(received_signal,n,l);
%display the LF value if display=1
if display==1
fprintf('Code: %s-rate %s (%i): n=%i,l=%i, Cost_function_CP=%f \n',rate_temp,code_name_temp,num_code_temp,n,l,LF(code_index));
end
end
[maximum_LF,index_detected]=max(LF);
code_name_detected=code_name_list(index_detected);
rate_detected=rate_list(index_detected);
num_detected=num_code_list(index_detected);
if display==1
fprintf('Optimal_Classifier: Code detected %s %s (%i)\n\n',cell2mat(code_name_detected),cell2mat(rate_detected),num_detected);
end