2 matlab tasks

profilelucky810
MIMOFBMCwithlikelihoodmethodsequenceofchannelestimation.rar

MIMO FBMC with likelihood method sequence of channel estimation/fbmcdesign.m

clc clear all inputmsg = randi([0 1],1,400); parallelform = reshape(inputmsg,100,[]); dataSymbolsIn = bi2de(parallelform); modsignal = qammod(dataSymbolsIn,16); mod_real=real(modsignal); mod_im=imag(modsignal); [y,t] = rcosflt(ones(1,1),4,8,'fir',.5,20); [y1,t1] = rcosflt(ones(1,1),4,8,'fir',.5,25); [y3,t3] = rcosflt(ones(1,1),4,8,'fir',.5,15); oddsignal=filter(y,1,mod_real); evensignal=filter(y1,1,mod_im); %filter3=filter(y3,1,inputmsg); A=[]; A=[A oddsignal]; b=[]; b=[b evensignal]; sumsignal=[A+b]; timesignal = ifft(sumsignal); serialsignal=reshape(timesignal,1,[]); for i=1:1:6 SNR(1,i) = 4*i; noisysig = awgn(serialsignal,SNR(1,i)); parallelform = reshape(noisysig,100,[]); fftsignal=fft(parallelform); realfft=real(fftsignal); imagfft=imag(fftsignal); rxoddsignal=filter(y,1,realfft); rxevenignal=filter(y3,1,imagfft); rr=rxoddsignal+1i*rxevenignal; demodsignal = qamdemod(rr,16); dataOutMatrix = de2bi(demodsignal); % demodsignal = qamdemod(sumreciver,16); % % dataOutMatrix = de2bi(demodsignal); outputsignals(i,:) = reshape(dataOutMatrix,1,[]); [numErrors(1,i),BER(1,i)]= biterr(inputmsg,outputsignals(i,:)); scatterplot(noisysig); title({'Scatter Plot Of Received Signal';[' SNR = ',num2str(SNR(1,i)),' db']}); end

MIMO FBMC with likelihood method sequence of channel estimation/MIMO FBMC with likelihood method sequence of channel estimation.docx

MIMO FBMC with likelihood method sequence of channel estimation

1) Change the code

+ implementation this code for filter banks multicarrier with

likelihood method sequence of channel estimation

+ add these requirements:

a) AWGN : SNR 2 : 2 : 15

b) MIMO Channel with filter bank

Note: Description of code:

a) fbmcdesign.m

This is a main program

b) MIMO_OFDM_LSE_CHAN_EST_LOOP.m & MMSE_CE:

used them for likelihood method sequence of channel estimation

C:\Users\A-M\AppData\Local\Microsoft\Windows\INetCache\Content.Word\IMG_1316.jpg C:\Users\A-M\AppData\Local\Microsoft\Windows\INetCache\Content.Word\IMG_1317.jpg

C:\Users\A-M\AppData\Local\Microsoft\Windows\INetCache\Content.Word\IMG_1318.jpg

2) Results:

a) plot input signal

C) plot filterd bank signal

e) output signal

f) bit error rate depend on this plot:

C:\Users\A-M\AppData\Local\Microsoft\Windows\INetCache\Content.Word\IMG_1324.jpg

image1.jpeg

image2.jpeg

image3.jpeg

image4.jpeg

MIMO FBMC with likelihood method sequence of channel estimation/MIMO_OFDM_LSE_CHAN_EST.m

function [ofdm chan] = MIMO_OFDM_LSE_CHAN_EST(ofdmIn,chanIn) %% Help % In this code we consider the least square error channel estimation for a % MIMO OFDM system. The user have access to the design parameters of % the MIMO OFDM system and the channel state information. The L-tap % Rayleigh fading channel is considered between any pair of the transmit and % receive antenna. The mean squared error of the LSE channel obtained % by the simulation result is compared with theory. % % source paper : "Optimal Training Design for MIMO OFDM Systems in Mobile Wireless Channels" % % Author : Hamid Ramezani % Author's contact : http://ens.ewi.tudelft.nl/~ramezani/ % Matlab Vession : 7.13.0.564 (R2011b) % %====================================================================== % Inputs %====================================================================== % Input parameters are (if not set the defalt value will be set) % ofdm.Nb = 1e2; % number of blocks % ofdm.Nt = 2; % number of transmit antennas % ofdm.Nr = 4; % number of receive antennas % ofdm.K = 128; % number of subcarriers % ofdm.G = 1/4; % Guard interval percentage % ofdm.Mod = 4; % QPSK Modulation % ofdm.PSpace = 1; % subcarrier space between two pilots % channel parameters % chan.SNR_dB = 15; % signal to noise ratio % chan.L = 6; % number of taps in each transmit-receive antenna % control parameters % ofdm.ifDemodulateData = 1; % (1,0) if 1, the code demodulates the transmitted via LS data and calculates the BER % ofdm.ifDisplayResults = 1; % (1,0) if 1, display the results in the command window %====================================================================== % Outputs %====================================================================== % The main outputs are listed below % chan.MSE_Theory % Minimum squared error of LSE channel estimation in theory % chan.MSE_Simulation % Minimum squared error of LSE channel estimation in simulations % ofdm.BER % Bit Error Rate if ofdm.ifDemodulateData = 1 % if you have any question about this code, and you have bought this % code, send me and email with title RAY01_MIMO_OFDM_LSE_CHAN. I will % reply you as soon as possible. % Copywrite: Written by Hamid Ramezani, all rights are reserved. % Distribution of this file is not allowed. %% Parameters % system parameters (independent) ofdm.Nb = 1e2; % number of blocks ofdm.Nt = 2; % number of transmit antenna ofdm.Nr = 4; % number of receive antenna ofdm.K = 128; % number of subcarriers ofdm.G = 1/4; % Guard interval percentage ofdm.Mod = 4; % QPSK Modulation ofdm.PSpace = 1; % pilot space between two pilots % channel parameters chan.SNR_dB = 15; % signal to noise ratio chan.L = 6; % number of channel taps between each transmit-receive antenna % control parameters ofdm.ifDemodulateData = 1; % (1,0) if 1, the code demodulates the transmitted data via LS algorithm, and calculates the BER ofdm.ifDisplayResults = 1; % (1,0) if 1, displays the results in the command window % inserting input data to the default data if nargin > 2 error('Only two arguments can be set as inputs') elseif nargin == 2 % updating the set parameters S = fieldnames(ofdmIn); for nS = 1:length(S) ofdm.(S{nS}) = ofdmIn.(S{nS}); end S = fieldnames(chanIn); for nS = 1:length(S) chan.(S{nS}) = chanIn.(S{nS}); end elseif nargin == 1 S = fieldnames(ofdmIn); for nS = 1:length(S) ofdm.(S{nS}) = ofdmIn.(S{nS}); end end % dependent parameters ofdm.PPos = 1:(ofdm.PSpace+1):ofdm.K; % OFDM pilot positionss ofdm.PL = length(ofdm.PPos); % Length of pilot subcarriers ofdm.DPos = setxor(1:ofdm.K,ofdm.PPos); % OFDM data positions ofdm.DL = length(ofdm.DPos); % Length of data subcarriers ofdm.BER = 0; % set the BER to zero chan.sigma = sqrt(10^(-0.1*chan.SNR_dB)); % noise power % normalization of the energy for the constelation temp = 0:ofdm.Mod-1; % possible symbols temp = qammod(temp,ofdm.Mod); % modulated symbols temp = abs(temp).^2; % power of each point in the constellation temp = mean(temp); % average energy of the constellation ofdm.ModNorm = 1/sqrt(temp); % normaliztion factor %% Data generation % symbol generation ofdm.d = randi(ofdm.Mod,ofdm.DL,ofdm.Nb,ofdm.Nt)-1; % generation of a DL by nB by Nt matrix of data symbols %% data Modulation ofdm.dMod = zeros(ofdm.K,ofdm.Nb,ofdm.Nt); % memory allocation for the ofdm blocks transmitted from each Tx antenna if ofdm.DL > 0 for nt = 1 : ofdm.Nt ofdm.dMod(ofdm.DPos,:,nt) = ofdm.ModNorm*qammod(ofdm.d(:,:,nt),ofdm.Mod); end end %% Pilot insertion for nt = 1 : ofdm.Nt ofdm.dMod(ofdm.PPos,:,nt) = repmat(exp(-sqrt(-1)*2*pi*(nt-1)*chan.L*(1:ofdm.PL).'/ofdm.PL),1,ofdm.Nb); end % checking the power of the transmit signal (it has to be 1 after normalization) ofdm.pow = var(ofdm.dMod(:))+abs(mean(ofdm.dMod(:)))^2; %% IFFT operation ofdm.ifft = zeros(ofdm.K,ofdm.Nb,ofdm.Nt); % memory allocation for the ofdm blocks transmitted from each Tx antenna after ifft for nt = 1 : ofdm.Nt ofdm.ifft(:,:,nt) = sqrt(ofdm.K)*ifft(ofdm.dMod(:,:,nt),ofdm.K); end %% Cyclic perfix % copy the end of signal to the begining of signal ofdm.ifftG = [ofdm.ifft(ofdm.K*(1-ofdm.G)+1:ofdm.K,:,:);ofdm.ifft]; %% Channel % for each block we generate a rayleigh fading MIMO channel which is % fixed over a block chan.Coeff = 1/sqrt(2)*1/sqrt(chan.L)*(randn(ofdm.Nt,ofdm.Nr,chan.L,ofdm.Nb)+sqrt(-1)*randn(ofdm.Nt,ofdm.Nr,chan.L,ofdm.Nb)); %% Channel pass and filter if ofdm.K*ofdm.G < chan.L+1 error('Guard interval is shorter than channel length, and the system does not function properly') end ofdm.Y = zeros(ofdm.K*(1+ofdm.G),ofdm.Nb,ofdm.Nr); for nb = 1 : ofdm.Nb for nt=1:ofdm.Nt for nr=1:ofdm.Nr ofdm.Y(:,nb,nr) = ofdm.Y(:,nb,nr) + filter(squeeze(chan.Coeff(nt,nr,:,nb)),1,ofdm.ifftG(:,nb,nt)); end end end % adding noise ofdm.Y = ofdm.Y + chan.sigma*1/sqrt(2)*( randn(ofdm.K*(1+ofdm.G),ofdm.Nb,ofdm.Nr)+... sqrt(-1)*randn(ofdm.K*(1+ofdm.G),ofdm.Nb,ofdm.Nr) ); %% Cyclic prefix removal ofdm.fftG = ofdm.Y(ofdm.K*ofdm.G+1:ofdm.K*(1+ofdm.G),:,:); %% FFT operation ofdm.fft = zeros(ofdm.K,ofdm.Nb,ofdm.Nr); for nr = 1 : ofdm.Nr ofdm.fft(:,:,nr) = 1/sqrt(ofdm.K)*fft(ofdm.fftG(:,:,nr),ofdm.K); end %% Channel estimation % building the first L columns of the fft matrix F = dftmtx(ofdm.K); F = F(:,1:chan.L); % Memory allocation for the estimated channel coefficients chan.CoeffEst = zeros(ofdm.Nt,ofdm.Nr,chan.L,ofdm.Nb); for nb = 1 : ofdm.Nb for nr = 1 : ofdm.Nr % Building matrix A (see the paper) chan.A = zeros(ofdm.PL,chan.L*ofdm.Nt); for nt = 1 : ofdm.Nt chan.A(:,(1:chan.L)+(nt-1)*chan.L) = diag(ofdm.dMod(ofdm.PPos,nb,nt))*F(ofdm.PPos,:); end ChanEst = pinv(chan.A)*ofdm.fft(ofdm.PPos,nb,nr); for nt = 1 : ofdm.Nt chan.CoeffEst(nt,nr,:,nb) = ChanEst((1:chan.L)+(nt-1)*chan.L); end end end %% MSE (Mean Square error calculation) chan.MSE_Simulation = var(chan.Coeff(:)-chan.CoeffEst(:)); chan.MSE_Theory = chan.sigma^2/ofdm.PL; if ofdm.ifDisplayResults disp(['MSE of channel estimation (theory) is : ',num2str(chan.MSE_Theory)]) disp(['MSE of channel estimation (simulation) is : ',num2str(chan.MSE_Simulation)]) end %% Demodulation if ofdm.ifDemodulateData == 1 && ofdm.DL > 0 % Building channel coefficients in frequency domain chan.CoeffEstFreq = zeros(ofdm.K,ofdm.Nt,ofdm.Nr,ofdm.Nb); for nb = 1 : ofdm.Nb for nr = 1 : ofdm.Nr for nt = 1 : ofdm.Nt chan.CoeffEstFreq(:,nt,nr,nb) = F*squeeze(chan.CoeffEst(nt,nr,:,nb)); end end end % demodulation ofdm.dDemod = zeros(ofdm.DL,ofdm.Nb,ofdm.Nt); for nb = 1 : ofdm.Nb for dl = 1 : ofdm.DL ofdm.dDemod(dl,nb,:) = pinv(reshape(chan.CoeffEstFreq(ofdm.DPos(dl),:,:,nb),ofdm.Nt,ofdm.Nr).')... *squeeze(ofdm.fft(ofdm.DPos(dl),nb,:)); end end % detection ofdm.dEst = zeros(ofdm.DL,ofdm.Nb,ofdm.Nt); for nt = 1 : ofdm.Nt ofdm.dEst(:,:,nt) = qamdemod(1/ofdm.ModNorm * ofdm.dDemod(:,:,nt),ofdm.Mod); end % BER calculation [~,ofdm.BER] = biterr(ofdm.d(:),ofdm.dEst(:),log2(ofdm.Mod)); if ofdm.ifDisplayResults disp(['BER is = ',num2str(ofdm.BER)]) end end

MIMO FBMC with likelihood method sequence of channel estimation/MIMO_OFDM_LSE_CHAN_EST_LOOP.m.txt

%% Help % In this code, we evaluate the performance of LSE MIMO OFDM channel % estimation, and compare the results with the theory. % In order to get further help about the algorithm type % "help MIMO_OFDM_LSE_CHAN_EST" % % Author : Hamid Ramezani % Author's contact : http://ens.ewi.tudelft.nl/~ramezani/ % Matlab Vession : 7.13.0.564 (R2011b) %% Clear clear close all clc %% Sweep parameters SNR_dBV = 3:1:15; % vector of SNR values in dB SNR_dBVL = length(SNR_dBV); % length of SNR vector nMonteCarlo = 1e2; % number of Monte Carlo to find the value of each point in the figure ofdmIn.Nt = 2; % number of transmit antennas ofdmIn.Nr = 3; % number of recieve antennas ofdmIn.ifDisplayResults = 0; % turn off the display % other parameters of ofdm can also be set. see help of MIMO_OFDM_LSE_CHAN_EST %% Outputs MSE_CHAN_SIM = zeros(nMonteCarlo,SNR_dBVL); % MSE of LSE channel estimation in simulation MSE_CHAN_THR = zeros(nMonteCarlo,SNR_dBVL); % MSE of LSE channel estimation in theory MSE_CHAN_BER = zeros(nMonteCarlo,SNR_dBVL); % BER of the MIMO OFDM with LSE channel estimation %% Loop cnt3 = 0; for cnt1 = 1 : SNR_dBVL chanIn.SNR_dB = SNR_dBV(cnt1); % load the SNR value for cnt2 = 1 : nMonteCarlo [ofdm chan] = MIMO_OFDM_LSE_CHAN_EST(ofdmIn,chanIn); %chan=MMSE_CE(Y,Xp,pilot_loc,Nfft,Nps,h,SNR); MSE_CHAN_SIM(cnt2,cnt1) = chan.MSE_Simulation; MSE_CHAN_THR(cnt2,cnt1) = chan.MSE_Theory; MSE_CHAN_BER(cnt2,cnt1) = ofdm.BER; % update the loop counter cnt3 = cnt3 + 1; disp([num2str(round(cnt3/(SNR_dBVL*nMonteCarlo)*1000)/10),' is done...']) end end %% Figures figure(1) clf semilogy(SNR_dBV,mean(MSE_CHAN_THR),'-r.',... SNR_dBV,mean(MSE_CHAN_SIM),'bx ') xlabel('SNR [dB]') ylabel('MSE of LSE channel estimation') grid on legend('Simulation','Theory') title(['Nt = ',num2str(ofdm.Nt),', Nr = ',num2str(ofdm.Nr)]) figure(2) clf semilogy(SNR_dBV,mean(MSE_CHAN_BER),'b') xlabel('SNR [dB]') ylabel('Bit error rate (BER)') grid on

MIMO FBMC with likelihood method sequence of channel estimation/MMSE_CE.m

function H_MMSE = MMSE_CE(Y,Xp,pilot_loc,Nfft,Nps,h,SNR) %function H_MMSE = MMSE_CE(Y,Xp,pilot_loc,Nfft,Nps,h,ts,SNR) % MMSE channel estimation function % Inputs: % Y = Frequency-domain received signal % Xp = Pilot signal % pilot_loc = Pilot location % Nfft = FFT size % Nps = Pilot spacing % h = Channel impulse response % ts = Sampling time % SNR = Signal-to-Noise Ratio[dB] % output: % H_MMSE = MMSE channel estimate %MIMO-OFDM Wireless Communications with MATLAB¢ç Yong Soo Cho, Jaekwon Kim, Won Young Yang and Chung G. Kang %2010 John Wiley & Sons (Asia) Pte Ltd %H = fft(h,N); snr = 10^(SNR*0.1); Np=Nfft/Nps; k=1:Np; H_tilde = Y(1,pilot_loc(k))./Xp(k); % LS estimate k=0:length(h)-1; %k_ts = k*ts; hh = h*h'; tmp = h.*conj(h).*k; %tmp = h.*conj(h).*k_ts; r = sum(tmp)/hh; r2 = tmp*k.'/hh; %r2 = tmp*k_ts.'/hh; tau_rms = sqrt(r2-r^2); % rms delay df = 1/Nfft; %1/(ts*Nfft); j2pi_tau_df = j*2*pi*tau_rms*df; K1 = repmat([0:Nfft-1].',1,Np); K2 = repmat([0:Np-1],Nfft,1); rf = 1./(1+j2pi_tau_df*(K1-K2*Nps)); K3 = repmat([0:Np-1].',1,Np); K4 = repmat([0:Np-1],Np,1); rf2 = 1./(1+j2pi_tau_df*Nps*(K3-K4)); Rhp = rf; Rpp = rf2 + eye(length(H_tilde),length(H_tilde))/snr; H_MMSE = transpose(Rhp*inv(Rpp)*H_tilde.'); % MMSE channel estimate