Commit 847a4203 authored by Florian Kaltenberger's avatar Florian Kaltenberger

moving project CORRIDOR to extras

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7399 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent fd45609d
function La = LanczosKernel(a,x0,samples)
min = floor(x0) - a;
max = ceil(x0) + a;
min(min<1)=1;
max(max>size(samples,2))=size(samples,2);
La=zeros(size(x0,2),1);
for i=1:size(x0,2)
La(i)=sinc((-x0(i)+(min(i):max(i)))).*sinc(((-x0(i)+(min(i):max(i)))/a))*samples(min(i):max(i))';
end
\ No newline at end of file
function received_f = OFDM_RX(received,num_carriers,useful_carriers,prefix_length,num_symbols_frame)
nant = size(received,2);
ofdm_symbol_length = num_carriers + prefix_length;
received_f = zeros(num_symbols_frame,useful_carriers,nant);
for j=0:num_symbols_frame-1;
ifblock=received(j*ofdm_symbol_length+(1:ofdm_symbol_length),:);
ifblock(1:prefix_length,:)=[];
fblock=fft(ifblock,[],1)/sqrt(num_carriers);
received_f(j+1,:,:) = [fblock(2:useful_carriers/2+1,:); fblock(end-useful_carriers/2+1:end,:)];
end
\ No newline at end of file
function [sig,sig_length] = OFDM_TX(num_carriers,num_zeros,prefix_length,input)
% OFDM Transmitter - DC removed
% sig is the output signal
% length is the length of the output signal
% num_carriers - number of sub-carriers (power of 2)
% num_zeros - number of zeros minus 1 (DC) in output spectrum (odd)
% prefix_length - length of cyclic prefix
% input - input dimensions (length = number_carriers - num_zeros - 1)
if (length(input) + num_zeros + 1 ~= num_carriers)
fprintf('error in lengths\n');
return;
end
ext_input = [0 input(1:length(input)/2) zeros(1,num_zeros) input((1+length(input)/2) : length(input))];
output_1 = ifft(ext_input);
sig = [output_1((num_carriers - prefix_length + 1) : num_carriers) output_1];
sig_length = length(sig);
function [sig, sig_f] = OFDM_TX_FRAME(num_carriers,num_zeros,prefix_length,num_symbols_frame,preamble_length)
% sig - output signal
% sig_length - output signal length
% num_carriers - number of sub-carriers
% num_zeros - number of zero carriers minus 1 (DC)
% prefix_length - length of cyclic prefix
% num_symbols_frame - number of symbols per OFDM frame
% preamble_length - length of 4-QAM preamble
num_useful_carriers = num_carriers - num_zeros -1;
sig = zeros(1,(num_carriers+prefix_length)*num_symbols_frame);
sig_f = zeros(num_symbols_frame,num_useful_carriers);
for k=1:preamble_length
QAM4_preamble = QAM_MOD(4,floor(256*abs(rand(1,num_useful_carriers/4))));
sig((k-1)*(num_carriers+prefix_length)+1:k*(num_carriers+prefix_length)) = OFDM_TX(num_carriers,num_zeros,prefix_length,QAM4_preamble);
sig_f(k,:) = QAM4_preamble;
end
for k=preamble_length+1:num_symbols_frame
QAM_data = QAM_MOD(256,floor(256*abs(rand(1,num_useful_carriers))));
sig((k-1)*(num_carriers+prefix_length)+1:k*(num_carriers+prefix_length)) = OFDM_TX(num_carriers,num_zeros,prefix_length,QAM_data);
sig_f(k,:) = QAM_data;
end
function [sig, sig_f] = OFDM_TX_FRAME_MIMO(num_carriers,num_zeros,prefix_length,num_symbols_frame,preamble_length,num_ant)
% sig - output signal
% sig_length - output signal length
% num_carriers - number of sub-carriers
% num_zeros - number of zero carriers minus 1 (DC)
% prefix_length - length of cyclic prefix
% num_symbols_frame - number of symbols per OFDM frame
% preamble_length - length of 4-QAM preamble
% numant - number of antennas
num_useful_carriers = num_carriers - num_zeros -1;
if (num_ant ==1)
t_dec = 1;
f_dec = 1;
elseif (num_ant ==2)
t_dec = 1;
f_dec = 2;
elseif (num_ant == 4)
t_dec = 2;
f_dec = 4;
else
error('Only 1, 2 or 4 antennas supported');
end
sig = zeros(num_ant,(num_carriers+prefix_length)*num_symbols_frame);
sig_f = zeros(num_ant,num_symbols_frame,num_useful_carriers);
for a=1:num_ant
for k=(floor((a-1)/2)+1):t_dec:preamble_length
QAM4_preamble = zeros(1,num_useful_carriers);
QAM4_preamble(2*mod(a-1,2)+1:f_dec:num_useful_carriers) = QAM_MOD(4,floor(4*abs(rand(1,num_useful_carriers/f_dec))));
sig(a,(k-1)*(num_carriers+prefix_length)+1:k*(num_carriers+prefix_length)) = OFDM_TX(num_carriers,num_zeros,prefix_length,QAM4_preamble);
sig_f(a,k,:) = QAM4_preamble;
end
for k=preamble_length+1:num_symbols_frame
QAM_data = QAM_MOD(256,floor(4*abs(rand(1,num_useful_carriers))));
sig(a,(k-1)*(num_carriers+prefix_length)+1:k*(num_carriers+prefix_length)) = OFDM_TX(num_carriers,num_zeros,prefix_length,QAM_data);
sig_f(a,k,:) = QAM_data;
end
end
function [sig,sig_length] = QAM_MOD(size,input)
% sig - output symbols
% size - modulation size (4,16,256)
% input - vector of bytes to be modulated
AM2 = [-1 1];
AM4 = [-3 -1 1 3]; AM4 = 2*AM4/sqrt(AM4*AM4');
AM16 = [-15 -13 -11 -9 -7 -5 -3 -1 1 3 5 7 9 11 13 15]; AM16 = 4*AM16/sqrt(AM16*AM16');
sig = zeros(1,length(input));
sig_length = length(input);
for l=1:length(input)
if (size == 256)
sig(l) = (AM16(1+ floor((input(l)/16))) + sqrt(-1)*AM16(1+rem(input(l),16)))/sqrt(2);
elseif (size == 16)
sig(l) = (AM4(1+rem(floor(input(l)/4),4)) + sqrt(-1)*AM4(1+rem(input(l),4)))/sqrt(2);
elseif (size == 4)
sig(l) = (AM2(1+rem(floor(input(l)/2),2)) + sqrt(-1)*AM2(1+rem(input(l),2)))/sqrt(2);
end
end
close all;
clear all;
%n_carriers=1;% 1 for UHF files, 2 for 2.6GHz files
%file='E:\EMOS\corridor\postprocessed data\eNB_data_UHF_20140519_run4.mat'; % mat file
%file='E:\EMOS\corridor\postprocessed data\eNB_data_20140331_UHF_run2.mat'; % mat file
n_carriers=2;
n_trials=2;
n_runs=1;
%file='E:\EMOS\corridor\postprocessed data\eNB_data_20140331_2.6GHz_run2.mat'; % mat file
%file='eNB_data_UHF_20140519_run4.mat'; % mat file
file='eNB_data_20140519_2.6GHz_run1.mat'; % mat file
post_processed_data=load(file, 'PDD_totala','PDP_totala','delay_doppler_profile_beforea','delay_doppler_profile_duringa','delay_doppler_profile_aftera');
%post_processed_data=load(file, 'PDD_totala','PDP_totala');
if(n_carriers==2)
post_processed_data=load(file, 'PDD_totala','PDP_totala','delay_doppler_profile_beforea','delay_doppler_profile_duringa','delay_doppler_profile_aftera','PDD_totalb','PDP_totalb','delay_doppler_profile_beforeb','delay_doppler_profile_duringb','delay_doppler_profile_afterb');
end
PDDta=post_processed_data(1,1).PDD_totala;
PDPta=post_processed_data(1,1).PDP_totala;
delay_doppler_profile_beforea=post_processed_data(1,1).delay_doppler_profile_beforea;
delay_doppler_profile_duringa=post_processed_data(1,1).delay_doppler_profile_duringa;
delay_doppler_profile_aftera=post_processed_data(1,1).delay_doppler_profile_aftera;
if(n_carriers==2)
PDDtb=post_processed_data(1,1).PDD_totalb;
PDPtb=post_processed_data(1,1).PDP_totalb;
delay_doppler_profile_beforeb=post_processed_data(1,1).delay_doppler_profile_beforeb;
delay_doppler_profile_duringb=post_processed_data(1,1).delay_doppler_profile_duringb;
delay_doppler_profile_afterb=post_processed_data(1,1).delay_doppler_profile_afterb;
end
if n_trials==1
if n_runs==1
block_before=50;
block_during=90;
block_after=130;
end
if n_runs==2
if n_carriers==1% we have changed the orientation of the antennas for the UHF channel in Trial 1 Run 2
block_before=60;
block_during=155;
block_after=190;
end
if n_carriers==2
block_before=60;
block_during=107;
block_after=140;
end
end
end
if n_trials==2
if n_runs==1
block_before=50;
block_during=91;
block_after=140;
end
if n_runs==2
block_before=45;
block_during=77;
block_after=120;
end
if n_runs==3
block_before=45;
block_during=83;
block_after=120;
end
if n_runs==4
block_before=34;
block_during=43;
block_after=90;
end
end
%% Doppler spectrum (choose the block you want to read)
block = 20;
figure(1)
for i=1:size(PDDta,3)
for j=1:size(PDDta,4)
subplot(size(PDDta,3),size(PDDta,4),(i-1)*size(PDDta,4)+j)
F=-(100*120/2-1)*7.68E6/(2*100*120/2)/1280:7.68E6/(100*120/2)/1280:(100*120/2-1)*7.68E6/(2*100*120/2)/1280;
if (n_carriers==2)
F=-(50*120/2-1)*30.72E6/(2*50*120/2)/5120:30.72E6/(50*120/2)/5120:(50*120/2-1)*30.72E6/(2*50*120/2)/5120;
end
plot(F,10*log(PDDta(:,block,i,j)));
ylabel('power [dB]')
xlabel('Doppler shift [Hz]')
end
end
if(n_carriers==2)
figure(2)
for i=1:size(PDDtb,3)
for j=1:size(PDDtb,4)
subplot(size(PDDtb,3),size(PDDtb,4),(i-1)*size(PDDtb,4)+j)
F=-(50*120/2-1)*15.36E6/(2*50*120/2)/2560:15.36E6/(50*120/2)/2560:(50*120/2-1)*15.36E6/(2*50*120/2)/2560;
plot(F,10*log(PDDtb(:,block,i,j)));
end
end
end
%% Power Delay Profile (choose the frame you want to read)
frame = 3000;
figure(3)
for i=1:size(PDDta,3)
for j=1:size(PDDta,4)
T=1:1:(size(PDPta,1));
tau=linspace(0,300/4/4.5E6,300);
T=1:1:(size(PDPta,1));
if n_carriers==2
tau=linspace(0,1200/4/18E6,1200/4);
end
subplot(size(PDDta,3),size(PDDta,4),(i-1)*size(PDDta,4)+j)
plot(10*log10(PDPta(frame,:,i,j)));
xlabel('delay [s]')
ylabel('time [*10 ms]')
end
end
if(n_carriers==2)
figure(4)
for i=1:size(PDDtb,3)
for j=1:size(PDDtb,4)
T=1:1:(size(PDPtb,1));
tau=linspace(0,600/4/18E6,600/4);
subplot(size(PDDtb,3),size(PDDtb,4),(i-1)*size(PDDtb,4)+j)
plot(10*log10(PDPtb(frame,:,i,j)));
xlabel('delay [s]')
ylabel('time [*10 ms]')
end
end
end
%% Total doppler spectrum in pseudocolor plot
doppler_profile_figures_dir = 'E:\byiringi\Matlab Plots\Doppler Shift pcolor plots new sync\';
h=figure(5);
hold off
for i=1:size(PDDta,3)
for j=1:size(PDDta,4)
T=1:1:size(PDDta,2);
F=-(100*120/2-1)*7.68E6/(2*100*120/2)/1280:7.68E6/(100*120/2)/1280:(100*120/2-1)*7.68E6/(2*100*120/2)/1280;
filename=sprintf('Trial %d Run %d UHF.fig',n_trials,n_runs);
if(n_carriers==2)
F=-(50*120/2-1)*30.72E6/(2*50*120/2)/5120:30.72E6/(50*120/2)/5120:(50*120/2-1)*30.72E6/(2*50*120/2)/5120;
filename=sprintf('Trial %d Run %d 2.6 GHz Carrier 2a.fig',n_trials,n_runs);
end
subplot(size(PDDta,3),size(PDDta,4),(i-1)*size(PDDta,4) + j);
pcolor(T,F,10*log10( PDDta(:,:,i,j)));
shading flat
%colormap hot
bara=colorbar;
%ylim([])
%xlim([])
xlabel('time [s]')
ylabel('Doppler shift [Hz]')
ylabel(bara,'Power [dB]')
end
end
saveas(h,strcat(doppler_profile_figures_dir, filename));
% for i=1:size(PDDta,1)
% for j=1:size(PDDta,2)
% if 10*log10(PDDta(i,j,1,1))<115
% PDDta(i,j,1,1)=10^11.5;
% end
% end
%
% end
% figure (15)
%
% T=1:1:size(PDDta,2);
% F=-(100*120/2-1)*7.68E6/(2*100*120/2)/1280:7.68E6/(100*120/2)/1280:(100*120/2-1)*7.68E6/(2*100*120/2)/1280;
% if(n_carriers==2)
% F=-(50*120/2-1)*30.72E6/(2*50*120/2)/5120:30.72E6/(50*120/2)/5120:(50*120/2-1)*30.72E6/(2*50*120/2)/5120;
% end
%
%
%
%
% pcolor(T,F,10*log10( PDDta(:,:,1,1)));
% shading flat
% colormap hot
% bara=colorbar;
% %ylim([])
% %xlim([])
% xlabel('time [s]')
% ylabel('Doppler shift [Hz]')
if(n_carriers==2)
h=figure(6);
for i=1:size(PDDtb,3)
for j=1:size(PDDtb,4)
T=1:1:size(PDDtb,2);
F=-(50*120/2-1)*15.36E6/(2*50*120/2)/2560:15.36E6/(50*120/2)/2560:(50*120/2-1)*15.36E6/(2*50*120/2)/2560;
filename=sprintf('Trial %d Run %d 2.6 GHz Carrier 2b.fig',n_trials,n_runs);
subplot(size(PDDtb,3),size(PDDtb,4),(i-1)*size(PDDtb,4) + j);
pcolor(T,F,10*log10( PDDtb(:,:,i,j)));
shading flat
barb=colorbar;
%colormap hot
%ylim([])
%xlim([])
xlabel('time [s]')
ylabel('Doppler shift [Hz]')
ylabel(barb,'Power [dB]')
end
end
saveas(h,strcat(doppler_profile_figures_dir, filename));
end
%% Total Power Delay Profile in pseudocolor
power_delay_profile_figures_dir = 'E:\byiringi\Matlab Plots\PDP pcolor plots new sync\';
h=figure(7);
for i=1:size(PDDta,3)
for j=1:size(PDDta,4)
tau=linspace(0,300/4/4.5E6,300/4);
T=1:1:(size(PDPta,1));
filename=sprintf('Trial %d Run %d UHF.fig',n_trials,n_runs);
if n_carriers==2
tau=linspace(0,1200/4/18E6,1200/4);
filename=sprintf('Trial %d Run %d 2.6 GHz Carrier 2a.fig',n_trials,n_runs);
end
subplot(size(PDDta,3),size(PDDta,4),(i-1)*size(PDDta,4)+j)
pcolor(tau,T,10*log10(PDPta(:,:,i,j)));
bara=colorbar;
shading flat
%colormap hot
xlabel('delay [s]')
ylabel('time [*10 ms]')
ylabel(bara,'Power [dB]')
end
end
saveas(h,strcat(power_delay_profile_figures_dir, filename));
% for i=1:size(PDPta,1)
% for j=1:size(PDPta,2)
% if 10*log10(PDPta(i,j,1,1))<57
% PDPta(i,j,1,1)=10^5.7;
% end
% end
%
% end
% figure (17)
% tau=linspace(0,300/4/4.5E6,300/4);
% T=1:1:(size(PDPta,1));
% if n_carriers==2
% tau=linspace(0,1200/4/18E6,1200/4);
% end
%
% pcolor(tau,T,10*log10(PDPta(:,:,1,1)));
% bara=colorbar;
% shading flat
% colormap hot
% xlabel('delay [s]')
% ylabel('time [*10 ms]')
if(n_carriers==2)
h=figure(8);
for i=1:size(PDDtb,3)
for j=1:size(PDDtb,4)
tau=linspace(0,600/4/9E6,600/4);
T=1:1:(size(PDPtb,1));
filename=sprintf('Trial %d Run %d 2.6 GHz Carrier 2b.fig',n_trials,n_runs);
subplot(size(PDDtb,3),size(PDDtb,4),(i-1)*size(PDDtb,4)+j)
pcolor(tau,T,10*log10(PDPtb(:,:,i,j)));
barb=colorbar;
shading flat
%colormap hot
xlabel('delay [s]')
ylabel('time [*10 ms]')
ylabel(barb,'Power [dB]')
end
end
saveas(h,strcat(power_delay_profile_figures_dir, filename));
end
%% Delay Doppler Spectrum before, during and after the passing of the train
figure(9)
tau=linspace(0,300/4/4.5E6,300/4);
F=-(100*120/2-1)*7.68E6/(2*100*120/2)/1280:7.68E6/(100*120/2)/1280:(100*120/2-1)*7.68E6/(2*100*120/2)/1280;
if(n_carriers==2)
tau=linspace(0,1200/4/18E6,1200/4);
F=-(50*120/2-1)*30.72E6/(2*50*120/2)/5120:30.72E6/(50*120/2)/5120:(50*120/2-1)*30.72E6/(2*50*120/2)/5120;
end
subplot(1,3,1)
pcolor(tau,F,10*log10(delay_doppler_profile_beforea(:,:)))
shading flat
colormap hot
bar1=colorbar;
xlabel('delay [s]')
ylabel('Doppler shift [Hz]')
ylabel(bar1,'Power [dB]')
title(sprintf('Delay Doppler Spectrum for UHF-Trial %d-Run %d-Block %d ',n_trials,n_runs,block_before));
if(n_carriers==2)
title(sprintf('Delay Doppler Spectrum for 2.6GHz Carrier 1-Trial %d-Run %d-Block %d ',n_trials,n_runs,block_before));
end
subplot(1,3,2)
pcolor(tau,F,10*log10(delay_doppler_profile_duringa(:,:)))
shading flat
colormap hot
bar2=colorbar;
xlabel('delay [s]')
ylabel('Doppler shift [Hz]')
ylabel(bar2,'Power [dB]')
title(sprintf('Delay Doppler Spectrum for UHF-Trial %d-Run %d-Block %d ',n_trials,n_runs,block_during));
if(n_carriers==2)
title(sprintf('Delay Doppler Spectrum for 2.6GHz Carrier 1-Trial %d-Run %d-Block %d ',n_trials,n_runs,block_during));
end
subplot(1,3,3)
pcolor(tau,F,10*log10(delay_doppler_profile_aftera(:,:)))
shading flat
colormap hot
bar3=colorbar;
xlabel('delay [s]')
ylabel('Doppler shift [Hz]')
ylabel(bar3,'Power [dB]')
title(sprintf('Delay Doppler Spectrum for UHF-Trial %d-Run %d-Block %d ',n_trials,n_runs,block_after));
if(n_carriers==2)
title(sprintf('Delay Doppler Spectrum for 2.6GHz Carrier 1-Trial %d-Run %d-Block %d ',n_trials,n_runs,block_after));
end
if(n_carriers==2)
figure(10)
tau=linspace(0,600/4/9E6,600/4);
F=-(50*120/2-1)*15.36E6/(2*50*120/2)/2560:15.36E6/(50*120/2)/2560:(50*120/2-1)*15.36E6/(2*50*120/2)/2560;
subplot(1,3,1)
pcolor(tau,F,10*log10(delay_doppler_profile_beforeb(:,:)))
shading flat
colormap hot
bar4=colorbar;
xlabel('delay [s]')
ylabel('Doppler shift [Hz]')
ylabel(bar4,'Power [dB]')
title(sprintf('Delay Doppler Spectrum for 2.6GHz Carrier 2-Trial %d-Run %d-Block %d ',n_trials,n_runs,block_before));
subplot(1,3,2)
pcolor(tau,F,10*log10(delay_doppler_profile_duringb(:,:)))
shading flat
bar5=colorbar;
colormap hot
xlabel('delay [s]')
ylabel('Doppler shift [Hz]')
ylabel(bar5,'Power [dB]')
title(sprintf('Delay Doppler Spectrum for 2.6GHz Carrier 2-Trial %d-Run %d-Block %d ',n_trials,n_runs,block_during));
subplot(1,3,3)
pcolor(tau,F,10*log10(delay_doppler_profile_afterb(:,:)))
shading flat
bar6=colorbar;
colormap hot
xlabel('delay [s]')
ylabel('Doppler shift [Hz]')
ylabel(bar6,'Power [dB]')
title(sprintf('Delay Doppler Spectrum for 2.6GHz Carrier 2-Trial %d-Run %d-Block %d ',n_trials,n_runs,block_after));
end
\ No newline at end of file
function H_dpss = dpss_smooth(H,V,Dopt,f_start)
alpha = V(f_start:4:end,1:Dopt)'*H.';
H_dpss = V(:,1:Dopt)*alpha;
\ No newline at end of file
close all
clear all
enable_plots=2; %eanbles figures
%% preload and init data
addpath('../../../openair1/PHY/LTE_REFSIG');
primary_synch; %loads the primary sync signal
pss_t = upsample(primary_synch0_time,4);
%load('E:\EMOS\corridor\ofdm_pilots_sync_2048_v7.mat');
load('ofdm_pilots_sync_30MHz.mat');
ofdm_symbol_length = num_carriers + prefix_length;
frame_length = ofdm_symbol_length*num_symbols_frame;
useful_carriers = num_carriers-num_zeros-1;
%filename = 'E:\EMOS\corridor2\eNB_data_20140321_184441.EMOS';
filename = 'D:\711MHz\eNB_data_20140324_113931.EMOS';
samples_slot = 7680/2;
slots_per_frame = 20;
nframes = 100;
nant=3;
d = dir(filename);
nblocks = floor(d.bytes/(samples_slot*slots_per_frame*nframes*nant*4));
PDP_total = zeros(nblocks*nframes,useful_carriers/4);