0001 function [ C_est, N0_dB_est ] = ChannelEstimator(z, L, d_TR, Para, options, causality)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 if exist('options','var') == 0
0048 options='Preamble';
0049 end
0050 switch options
0051 case 'ScatteredPilots'
0052 PilotSubcarriers=Para.ScatteredPilotSubcarriers;
0053 case 'Preamble'
0054 PilotSubcarriers=Para.PreamblePilotSubcarriers;
0055 otherwise
0056 error('Options type not defined for this function')
0057 end
0058
0059 switch Para.Modulation
0060 case 'FBMC-OQAM'
0061 factor=2;
0062 case 'CP-OFDM'
0063 factor=1;
0064 otherwise
0065 error('Modulation not implemented')
0066 end
0067
0068 if exist('causality','var') == 0
0069 causality=1;
0070 end
0071 switch causality
0072 case 1
0073 Sigma=[eye(L); zeros(Para.nSubcarriers-L,L)];
0074 C_est=zeros(Para.N_R,Para.N_T,L);
0075 case 0
0076 Sigma=[eye(L), zeros(L,L);zeros(Para.nSubcarriers-2*L,2*L);zeros(L,L) eye(L)];
0077 C_est=zeros(Para.N_R,Para.N_T,2*L);
0078 otherwise
0079 error('causality argument should be set to zero or one')
0080 end
0081
0082 if Para.N_R==1
0083 H_pilot_subcarriers=zeros(Para.nSubcarriers,1);
0084 H_pilot_subcarriers(PilotSubcarriers)=z(PilotSubcarriers,1)./d_TR(PilotSubcarriers);
0085 F=exp(-1j*2*pi/Para.nSubcarriers*(0:Para.nSubcarriers-1)'*(0:Para.nSubcarriers-1));
0086 v=zeros(Para.nSubcarriers,1);
0087 v(PilotSubcarriers)=1;
0088 S=diag(v);
0089 Gamma=S*F*Sigma;
0090 error_temp=zeros(Para.N_R,Para.N_T);
0091 for index_N_T=1:Para.N_T
0092 for index_N_R=1:Para.N_R
0093 C_est(index_N_R,index_N_T,:)=Gamma\H_pilot_subcarriers;
0094 temp_reconstruct=Gamma*squeeze(C_est(index_N_R,index_N_T,:));
0095 error_temp(index_N_R,index_N_T)=mean(abs( temp_reconstruct(PilotSubcarriers)-squeeze(H_pilot_subcarriers(PilotSubcarriers))).^2);
0096 end
0097 end
0098 N0_dB_est=10*log10(mean(mean(error_temp)));
0099 else
0100 F_pilot=1/sqrt(Para.N_T)*exp(-1j*2*pi/Para.N_T*(0:Para.N_T-1)'*(0:Para.N_T-1) );
0101 H_pilot_subcarriers=zeros(Para.N_R,Para.N_T,Para.nSubcarriers);
0102 for m=PilotSubcarriers
0103 H_pilot_subcarriers(:,:,m)= squeeze(z(:,m,1:factor:factor*Para.N_T))*F_pilot'./d_TR(m);
0104 end
0105
0106 F=exp(-1j*2*pi/Para.nSubcarriers*(0:Para.nSubcarriers-1)'*(0:Para.nSubcarriers-1));
0107 v=zeros(Para.nSubcarriers,1);
0108 v(PilotSubcarriers)=1;
0109 S=diag(v);
0110 Gamma=S*F*Sigma;
0111 error_temp=zeros(Para.N_R,Para.N_T);
0112 for index_N_T=1:Para.N_T
0113 for index_N_R=1:Para.N_R
0114 C_est(index_N_R,index_N_T,:)=Gamma\squeeze(H_pilot_subcarriers(index_N_R,index_N_T,:) );
0115 temp_reconstruct=Gamma*squeeze(C_est(index_N_R,index_N_T,:));
0116 error_temp(index_N_R,index_N_T)=mean(abs( temp_reconstruct(PilotSubcarriers)-squeeze(H_pilot_subcarriers(index_N_R,index_N_T,PilotSubcarriers))).^2);
0117 end
0118 end
0119 N0_dB_est=10*log10(mean(mean(error_temp)));
0120 end
0121
0122 if causality==0
0123 temp=C_est;
0124 C_est=zeros(Para.N_R,Para.N_T,Para.nSubcarriers);
0125 for index_N_T=1:Para.N_T
0126 for index_N_R=1:Para.N_R
0127 C_est(index_N_R,index_N_T,:)=Sigma*squeeze(temp(index_N_R,index_N_T,:));
0128 end
0129 end
0130 end
0131 end
0132