function analyz_10Ge_output_data
carr_num = 128;
raw_data = importdata('mkid_newG9eL2_all.txt');
size (raw_data);
diff=1;
i=1;
while diff ~= 0
diff = raw_data(i+1,1)- raw_data(i,1);
i = i+1;
end
start_i = i; % i is the second time stamp, first 2 time is 183 and 184, next 2 is 441 & 442
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Plot a power spectrum%
m=1;
for i =1:2:(2*carr_num-1)
I_onesample=raw_data(start_i+i,1);
Q_onesample=raw_data(start_i+i+1,1);
compl_onesample = complex(I_onesample, Q_onesample)/(2^15 *27);
power_onesample(m) = abs(compl_onesample);
m=m+1;
end
plot(20*log10(power_onesample),'.r')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%plot time stamps
time1=raw_data(start_i-1:(2*carr_num+2):end,1);
time2=raw_data(start_i:(2*carr_num+2):end,1);
figure
plot(time1,'.r')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% calculated how long the data has been taken
% verify the correctness of the time stamps
correct_time = 0;
time_len = size(time1)
for i =1:1:(time_len(1,1)-1)
if (time1(i+1)-time1(i))~=26
sprintf('seperation check failed at %d', i)
else
correct_time = correct_time+1;
end
end
sprintf('correct_time is %d', correct_time+1)
if correct_time+1 == time_len(1,1) & (time1(time_len(1,1),1) - time1(1,1))/26 == correct_time
sprintf('time sample total length and seperation match well')
else
sprintf('there is error in time stamp')
end
if time1 == time2
sprintf('2 time stamp matched well')
else
sprintf('2 time stamp does not match')
end
daq_duration = time_len(1,1)/100;
sprintf('total DAQ duration is around %i seconds', round(daq_duration))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Seperate I and Q for each carrier
size (raw_data)
%(((2*carr_num+2)*((time_len(1,1) -1)-1)-start_i-1))
%(2*carr_num+2)
I_all= zeros((time_len(1,1)-2 ),128);
Q_all= zeros((time_len(1,1)-2 ),128);
m=1;
for i =1:2:(2*carr_num-1)
%for i =1:2:30
%size(raw_data(start_i+i:(2*carr_num+2):((2*carr_num+2)*((time_len(1,1) -1)-1)-start_i-1),1))
%size(raw_data(start_i+i+1:(2*carr_num+2):((2*carr_num+2)*((time_len(1,1) -1)-1)-start_i-2),1))
I_all(:,m)=raw_data(start_i+i:(2*carr_num+2):((2*carr_num+2)*((time_len(1,1) -1)-1)+start_i),1);
Q_all(:,m)=raw_data(start_i+i+1:(2*carr_num+2):((2*carr_num+2)*((time_len(1,1) -1)-1)+start_i+1),1);
m=m+1;
m
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% make a rotation
%%%%%%%%%%%%%%%%%%%%%%%%%%%
complex_all = complex(I_all, Q_all);
for m =1:1:128
complex_all_rotated(:,m) = conj(mean(complex_all(:,m)))*complex_all(:,m)/(abs(mean(complex_all(:,m))));
end
I_all = real(complex_all_rotated);
Q_all = imag(complex_all_rotated);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% calculate the correlation%
%size(I_all(:,2))
size(I_all)
size( corrcoef(I_all))
I_correlation = corrcoef(I_all);
Q_correlation = corrcoef(Q_all);
figure
%contour(I_correlation,'.')
%imagesc (I_correlation)
[i,j] = find(Q_correlation > 0.8);
[i,j]
pcolor(I_correlation)
Q_correlation = corrcoef(Q_all);
figure
contour(Q_correlation,'.')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end