% Script for drawing the EXIT chart of the UMTS turbo code, as specified
% in ETSI TS 125 212 (search for it on Google if you like)
% BPSK modulation over an AWGN channel is assumed.
% Copyright (C) 2010 Robert G. Maunder
% This program is free software: you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by the
% Free Software Foundation, either version 3 of the License, or (at your
% option) any later version.
% This program is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
% Public License for more details.
% The GNU General Public License can be seen at http://www.gnu.org/licenses/.
d_c = 4;
IA_count = 11; % Choose how many points to plot in the EXIT functions
block_count = 100;
frame_count = 100;
IAs = (0:(IA_count-1))/(IA_count-1);
IE_means = zeros(1,IA_count);
IE_stds = zeros(1,IA_count);
% Determine each point in the EXIT functions
for IA_index = 1:IA_count
IEs = zeros(1,frame_count);
% This runs the simulation long enough to produce smooth EXIT functions.
for frame_index = 1:frame_count
a = round(rand(d_c-1,block_count));
b = [a;mod(sum(a,1),2)];
apriori = generate_llrs(b,IAs(IA_index));
extrinsic = zeros(size(apriori));
for block_index = 1:block_count
extrinsic(:,block_index) = check_node(apriori(:,block_index));
end
IEs(frame_index) = measure_mutual_information_averaging(extrinsic);
end
% Store the mean and standard deviation of the results
IE_means(IA_index) = mean(IEs);
IE_stds(IA_index) = std(IEs);
end
% Create a figure to plot the results.
figure;
axis square;
title('EXIT Function of CND with Bands');
ylabel('I_A');
xlabel('I_E');
xlim([0,1]);
ylim([0,1]);
hold on;
% Plot the EXIT function for CND
plot(IE_means,IAs,'-');
plot(IE_means+IE_stds,IAs,'--');
plot(IE_means-IE_stds,IAs,'--');
hold on;
%
%
%
%
%
%
% clear all
%
% SNR = -4; % Choose the SNR
% frame_count = 1000; % Choose how many frames to simulate
% IA_count = 11; % Choose how many points to plot in the EXIT functions
% histogram_method = 0; % Choose whether to use the histogram or the averaging method of measuring mutual information
% d_c =[4,8,16,32];
% dc=[3,7,15,31];
% inputlength=[192,224,240,248];
%
% % Convert from SNR (in dB) to noise power spectral density.
% N0 = 1/(10^(SNR/10));
%
%
%
% %each degree of cnd
% for t=1:4
% % Calculate the MIs to use for the a priori LLRs
% IAs = (0:(IA_count-1))/(IA_count-1);%11??0,0.1.???1
% IE_means = zeros(1,IA_count);
% IE_stds = zeros(1,IA_count);
% % Determine each point in the EXIT functions
% for IA_index = 1:IA_count
%
% IEs = zeros(1,frame_count);
%
% % This runs the simulation long enough to produce smooth EXIT functions.
% for frame_index = 1:frame_count
%
% % Generate some random bits.
% a=round(rand(1,inputlength(t)))
%
% %insert parity bits
% insert=zeros(1,length(a)/dc(t));
% suminsert=zeros(1,length(a)/dc(t));
%
% k=1;
% %caculate sum of each division
% for j=dc(t):dc(t):length(a);
% suminsert(k)=a(j)+a(j-1)+a(j-2);
% k=k+1;
% end
%
% %caculate the insert vector
% for i=1:length(a)/dc(t)
% insert(i)= mod(suminsert(i),2);
% end
%
% b=reshape([reshape(a,dc(t),length(a)/dc(t));insert],1,length(a)+length(a)/dc(t))
%
%
%
%
% % % BPSK modulate them
% % a_tx = -2*(a-0.5);
% % c_tx = -2*(c-0.5);
% % e_tx = -2*(e-0.5);
% %
% % % Send the BPSK signal over an AWGN channel
% % a_rx = a_tx + sqrt(N0/2)*(randn(size(a_tx))+i*randn(size(a_tx)));
% % c_rx = c_tx + sqrt(N0/2)*(randn(size(c_tx))+i*randn(size(c_tx)));
% % e_rx = e_tx + sqrt(N0/2)*(randn(size(e_tx))+i*randn(size(e_tx)));
% %
% % % BPSK demodulator
% % % These labels match those used in Figure 2.13 of Liang Li's nine month report.
% % a_c = (abs(a_rx+1).^2-abs(a_rx-1).^2)/N0;
% % c_c = (abs(c_rx+1).^2-abs(c_rx-1).^2)/N0;
% % e_c = (abs(e_rx+1).^2-abs(e_rx-1).^2)/N0;
%
% % Generate some random a priori LLRs.
% % These labels match those used in Figure 2.13 of Liang Li's nine month report.
% p_a = generate_llrs(b, IAs(IA_index));
%
% % Generate extrinsic LLRs from a priori LLRs
%
% p_e=check_node(p_a);
% % % Obtain the uncoded a priori input for component decoder 1.
% % % These labels match those used in Figure 2.13 of Liang Li's nine month report.
% % y_a = [a_a+a_c,e_c];
%
% % % Perform decoding.
% % % These labels match those used in Figure 2.13 of Liang Li's nine month report.
% % y_e = component_decoder(y_a,c_c);
%
% % Remove the LLRs corresponding to the termination bits.
% % These labels match those used in Figure 2.13 of Liang Li's nine month report.
% % a_e = y_e(1:length(a));
%
% % Measure the mutual information
% if histogram_method
% IEs(frame_index) = measure_mutual_information_histogram(p_e,b);
% else
% IEs(frame_index) = measure_mutual_information_averaging(p_e);
% end
%
% end
%
% % Store the mean and standard deviation of the results
% IE_means(IA_index) = mean(IEs);
% IE_stds(IA_index) = std(IEs);
% end
%
% % Create a figure to plot the results.
% figure(2);
% axis square;
% title('EXIT Function of CND with Bands');
% ylabel('I_A');
% xlabel('I_E');
% xlim([0,1]);
% ylim([0,1]);
%
% hold on;
%
%
%
% % Plot the EXIT function for CND
% plot(IE_means,IAs,'-');
% plot(IE_means+IE_stds,IAs,'--');
% plot(IE_means-IE_stds,IAs,'--');
% hold on;
%
%
%
% end
%
%
%